forked from HackYourFuture/JavaScript2
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (24 loc) · 825 Bytes
/
app.js
File metadata and controls
27 lines (24 loc) · 825 Bytes
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
'use strict';
{
const favoriteGames = [
// Replace with your own book titles
'harry_potter_chamber_secrets',
'call_of_the_wild',
'the_turtle',
'snowball_and_the_bunny_adventures',
'chicken_little',
];
// Replace with your own code
console.log(favoriteGames);
// document.body.onload = addElement;
// function displayGameTitles = () => {
let unorderedList = document.createElement("ul");
for (const gameIndex in favoriteGames) {
const listItem = document.createElement("li");
listItem.textContent = favoriteGames[gameIndex];
unorderedList.appendChild(listItem);
}
// add the newly created element and its content into the DOM
const currentDiv = document.getElementById("gameDiv");
document.body.insertBefore(unorderedList, currentDiv);
}