-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (44 loc) · 1.28 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
let score1 = 0;
let score2 = 0;
let homeScore = document.querySelector("#home-score");
let addOne1 = document.querySelector(".add-one1");
let addTwo1 = document.querySelector(".add-two1");
let addThree1 = document.querySelector(".add-three1");
let guestScore = document.querySelector("#guest-score");
let addOne2 = document.querySelector(".add-one2");
let addTwo2 = document.querySelector(".add-two2");
let addThree2 = document.querySelector(".add-three2");
let newGame = document.getElementById("new-game");
//home-score
addOne1.addEventListener("click", function () {
score1++;
homeScore.textContent = score1;
});
addTwo1.addEventListener("click", function () {
score1 += 2;
homeScore.textContent = score1;
});
addThree1.addEventListener("click", function () {
score1 += 3;
homeScore.textContent = score1;
});
//guest score
addOne2.addEventListener("click", function () {
score2++;
guestScore.textContent = score2;
});
addTwo2.addEventListener("click", function () {
score2 += 2;
guestScore.textContent = score2;
});
addThree2.addEventListener("click", function () {
score2 += 3;
guestScore.textContent = score2;
});
//new game
newGame.addEventListener("click", function () {
score1 = 0;
score2 = 0;
homeScore.textContent = score1;
guestScore.textContent = score2;
});