-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
30 lines (25 loc) · 834 Bytes
/
app.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
let teamOneScoreElement = document.getElementById("teamOneScore");
let teamTwoScoreElement = document.getElementById("teamTwoScore");
let points = 0;
function updateScore(element, pointsToAdd) {
points += pointsToAdd;
element.innerText = points;
}
function addPointsToTeam(teamNumber, pointsToAdd) {
if (teamNumber === 1) {
updateScore(teamOneScoreElement, pointsToAdd);
} else if (teamNumber === 2) {
updateScore(teamTwoScoreElement, pointsToAdd);
} else {
console.error("Invalid team number");
}
}
function resetScore() {
points = 0;
teamOneScoreElement.innerText = points;
teamTwoScoreElement.innerText = points;
}
// Example usage
addPointsToTeam(1, 1); // Adds 1 point to Team One
addPointsToTeam(2, 2); // Adds 2 points to Team Two
resetScore(); // Resets scores