-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
80 lines (64 loc) · 1.51 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* steps:
make design
1. essentials (fonts, background, score board design)
1a. fonts /
1b. background /
1c. score counter (black) (/)
1d. score texts (/)
2. buttons
2a. make buttons /
2b. copy design /
2c. make them a row /
2d. for each button, have onclick call assigned function /
3. js
3a. make functions
*/
let home = document.getElementById("score-home");
let away = document.getElementById("score-away");
let homeScore = 0
let awayScore = 0
home.textContent = homeScore
away.textContent = awayScore
console.log("home: " + homeScore)
console.log("away: " + awayScore)
/* functions */
/* home */
function increment1home() {
homeScore += 1
home.textContent = homeScore
console.log("home: " + homeScore)
}
function increment2home() {
homeScore += 2
home.textContent = homeScore
console.log("home: " + homeScore)
}
function increment3home() {
homeScore += 3
home.textContent = homeScore
console.log("home: " + homeScore)
}
/* away */
function increment1away() {
awayScore += 1
away.textContent = awayScore
console.log("away: " + awayScore)
}
function increment2away() {
awayScore += 2
away.textContent = awayScore
console.log("away: " + awayScore)
}
function increment3away() {
awayScore += 3
away.textContent = awayScore
console.log("away: " + awayScore)
}
/* new game */
function newGame() {
awayScore = 0
homeScore = 0
home.textContent = homeScore
away.textContent = awayScore
console.log("Reset the counter, new game!")
}