Skip to content

Commit 3700750

Browse files
committed
Ex5
1 parent a05f652 commit 3700750

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
<html>
1+
<!DOCTYPE html>
2+
<html lang="en">
23

3-
<!-- your html code goes in here -->
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Hobbies</title>
8+
</head>
9+
10+
<body>
11+
12+
<script src="ex5-myFavoriteHobbies.js"></script>
13+
</body>
414

515
</html>

Week2/js-exercises/ex5-myFavoriteHobbies.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
function createHTMLList(arr) {
1212
// your code goes in here
13+
const ulElement = document.createElement('ul');
14+
arr.forEach(arr => {
15+
const liElement = document.createElement('li');
16+
liElement.textContent = arr;
17+
ulElement.appendChild(liElement);
18+
})
19+
document.body.appendChild(ulElement);
1320
}
1421

1522
const myHobbies = [
@@ -18,4 +25,7 @@ const myHobbies = [
1825
'Programming',
1926
'Hanging out with friends',
2027
'Going to the gym',
21-
];
28+
];
29+
30+
createHTMLList(myHobbies);
31+

0 commit comments

Comments
 (0)