-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (22 loc) · 698 Bytes
/
index.js
File metadata and controls
24 lines (22 loc) · 698 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
let homeScore = 0;
let awayScore= 0;
document.querySelectorAll(".score-modifier-btn").forEach(button =>
{
button.addEventListener("click", () => {
let points = parseInt(button.dataset.points);
let team = button.dataset.team;
updateScore (team, points);
});
});
function updateScore(team, points){
if (team === "home"){
homeScore += points;
document.getElementById("home-score").textContent = homeScore;
} else if (team === "away") {
awayScore += points;
document.getElementById("away-score").textContent = awayScore;
}
else {
console.log("error retrieving needed information to update scoreboard!");
}
}