-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (59 loc) · 1.75 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//Scores
let homePoints = 0
let guestPoints = 0
function addPoint(team, points) {
if(team==="home") {
homePoints += points;
document.getElementById("home-score").textContent = homePoints;
}
else if(team==="guest") {
guestPoints += points;
document.getElementById("guest-score").textContent = guestPoints;
}
}
//Period
let periodCount = 0
function addPeriod() {
if (periodCount < 4) {
periodCount += 1;
document.getElementById("period-number").textContent = periodCount;
}
else if( periodCount < 5) {
periodCount = 0;
document.getElementById("period-number").textContent = periodCount;
}
}
//Fouls
let homeFouls = 0
let guestFouls = 0
function addFouls(team, fouls) {
if (team === "home" && fouls===1) {
homeFouls += fouls;
document.getElementById("foul-home").textContent = homeFouls;
}
else if (team === "home" && fouls===0) {
homeFouls = 0;
document.getElementById("foul-home").textContent = homeFouls;
}
else if (team === "guest" && fouls===1) {
guestFouls += fouls;
document.getElementById("foul-guest").textContent = guestFouls;
}
else if (team === "guest" && fouls===0) {
guestFouls = 0;
document.getElementById("foul-guest").textContent = guestFouls;
}
}
//New Game Button
function newGame() {
document.getElementById("home-score").textContent = 0
document.getElementById("guest-score").textContent = 0
document.getElementById("period-number").textContent = 0
document.getElementById("foul-home").textContent = 0
document.getElementById("foul-guest").textContent = 0
homePoints = 0
guestPoints = 0
periodCount = 0
homeFouls = 0
guestFouls = 0
}