-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
33 lines (27 loc) · 806 Bytes
/
script.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
let count = 0;
const image = document.querySelectorAll('img');
const score = document.querySelector('.score');
const timer = document.querySelector('.timer');
const goal = document.querySelector('.goal');
goal.innerHTML = prompt('Set Goal','60');
const interval = setInterval(() => {
timer.innerHTML--;
if(timer.innerHTML == 0 || timer.innerHTML < 0) {
alert('Time Up');
if(goal.innerHTML > score.innerHTML) {
alert('You Lose!!!');
}
else if(goal.innerHTML < score.innerHTML) {
alert('You Won!!!');
}
score.innerHTML = 0;
timer.innerHTML = 60;
}
}, 1000);
image.forEach(element=>{
element.addEventListener('click',countIncrease);
});
function countIncrease() {
count++;
score.innerHTML = count;
}