-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (27 loc) · 906 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
31
32
33
34
35
36
37
38
let numberContainer = document.getElementById("number");
let value = 0;
let btnIncrease = document.querySelector(".increase");
let btnDecrease = document.querySelector(".decrease");
let btnReset = document.querySelector(".reset");
btnIncrease.addEventListener("click", () => {
value++;
value % 10 === 0
? (numberContainer.style.color = "#8c3c23")
: (numberContainer.style.color = "#406485");
numberContainer.textContent = value;
});
btnDecrease.addEventListener("click", () => {
value--;
if (value < 0) {
value = 0;
alert("The number cannot be less than zero.");
}
value % 10 === 0
? (numberContainer.style.color = "#8c3c23")
: (numberContainer.style.color = "#406485");
numberContainer.textContent = value;
});
btnReset.addEventListener("click", () => {
value = 0;
numberContainer.textContent = value;
});