-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
36 lines (31 loc) · 1.19 KB
/
script.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
document.body.onload = initialize;
async function initialize() {
const json = await readJsonData();
const gamesArray = json["games"];
//addHeaderContainerToDocument();
for (let i = 0; i < gamesArray.length; i++) {
showGame(gamesArray[i]);
}
}
function showGame(singleGame) {
const gameContainer = document.createElement("div");
gameContainer.classList.add("game");
document.body.appendChild(gameContainer);
const dateContainer = document.createElement("div");
dateContainer.classList.add("gameDate");
dateContainer.innerText = `${singleGame["date"]}`;
gameContainer.appendChild(dateContainer);
const teamsContainer = document.createElement("div");
teamsContainer.classList.add("Teamclass");
teamsContainer.innerText = `${singleGame["team1"]} : ${singleGame["team2"]}`;
gameContainer.appendChild(teamsContainer);
const goalsContainer = document.createElement("div");
goalsContainer.classList.add("score");
goalsContainer.innerText = `${singleGame["goalsTeam1"]} : ${singleGame["goalsTeam2"]}`;
gameContainer.appendChild(goalsContainer);
}
async function readJsonData() {
const response = await fetch("./data.json");
const json = await response.json();
return json;
}