-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
54 lines (54 loc) · 1.37 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// select all buttons
const buttons = document.querySelectorAll('.btn');
// select count container (h1)
const counterDisplay = document.querySelector('h1');
// count pop up
const popUp = document.querySelector('p');
// intialize count
let count = 0;
buttons.forEach((button) => {
button.addEventListener('click', () => {
const buttonClass = button.classList;
if (buttonClass.contains('decrease')) {
count--;
counterDisplay.innerHTML = count;
}
if (buttonClass.contains('increase')) {
count++;
counterDisplay.innerHTML = count;
}
if (buttonClass.contains('reset')) {
count = 0;
counterDisplay.innerHTML = count;
popUp.classList.remove('show');
}
//styling
switch (true) {
case count > 0:
counterDisplay.style.color = 'green';
break;
case count < 0:
counterDisplay.style.color = 'red';
break;
default:
counterDisplay.style.color = 'black';
}
//pop
if (count >= 33) {
popUp.classList.add('show');
popUp.innerHTML = 'subhanallah';
}
if (count >= 66) {
popUp.innerHTML = 'Alhamdulillah';
}
if (count >= 99) {
popUp.innerHTML = 'allahu akbar';
}
if (count >= 100) {
popUp.innerHTML = 'la ilaha illalah';
}
if (count > 100 || count < 33) {
popUp.classList.remove('show');
}
});
});