-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathmainApp.js
34 lines (29 loc) · 828 Bytes
/
mainApp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const list = document.querySelector('.list');
fetch("./projects.json")
.then(response => {
return response.json();
})
.then(data => {
updateUI(data);
});
function updateUI(projects){
projects.forEach(({name, code, index}) => {
const listItem = document.createElement('li');
listItem.innerHTML = `
<span class="project-number">${index}</span>
<a href="/${name}/index.html" class="project-name">
${projectNameFormater(name)}
</a>
<a href=${code} class="container-links">
Code
</a>
`;
list.appendChild(listItem);
});
}
function projectNameFormater(name){
return name
.split('-')
.map(word => word[0].toUpperCase() + word.slice(1))
.join(' ');
}