-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (35 loc) · 789 Bytes
/
index.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
35
36
37
const gameButton = ({ name, location, img }) => {
const gameItem = document.createElement("article");
gameItem.classList.add("game-item");
gameItem.innerHTML = `
<img src="${img}" alt="${name}">
<div class="game-item-name">
<h2>${name}<h2>
</div>
`;
gameItem.addEventListener("click", () => {
document.location.href = location;
});
return gameItem;
};
const games = [
{
name: "Astroid Game",
location: "astroids",
img: "img/astroids.png",
},
{
name: "Snake Game",
location: "snake",
img: "img/snake.png",
},
{
name: "BFS Algorithm",
location: "bfs",
img: "img/bfs.png",
},
];
const gameList = document.getElementById("game-list");
games.forEach((game) => {
gameList.appendChild(gameButton(game));
});