-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (31 loc) · 854 Bytes
/
Copy pathscript.js
File metadata and controls
36 lines (31 loc) · 854 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
25
26
27
28
29
30
31
32
33
34
35
36
// COUNTER PROGRAM
const decreaseBtn = document.getElementById("decreaseBtn");
const resetBtn = document.getElementById("resetBtn");
const increaseBtn = document.getElementById("increaseBtn");
const countLabel = document.getElementById("countLabel");
let count = 0;
decreaseBtn .onclick = function() {
count--;
countLabel.textContent = count;
if(count === 0) {
countLabel.style.color = "black";
}
if(count < 0){
countLabel.style.color = "red";
}
}
resetBtn.onclick = function() {
count = 0;
countLabel.textContent = count;
countLabel.style.color = "black";
}
increaseBtn.onclick = function() {
count++;
countLabel.textContent = count;
if(count === 0) {
countLabel.style.color = "black";
}
if(count > 0){
countLabel.style.color = "green";
}
}