-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (30 loc) · 871 Bytes
/
script.js
File metadata and controls
34 lines (30 loc) · 871 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
const current = document.querySelector('.current');
const next = document.querySelector('.next');
const inp = document.querySelector('input');
let btn = document.querySelector('button');
btn.addEventListener('click', startCounter);
function startCounter() {
let finalScore = parseInt(inp.value);
if (inp.value === "") {
return;
}
if (finalScore > 9) {
return;
}
let currentScore = 0;
current.textContent = 0;
let interval = setInterval(function () {
currentScore++;
next.classList.add('animate');
next.textContent = currentScore;
setTimeout(() => {
next.classList.remove('animate');
current.textContent = currentScore;
}, 500)
if (currentScore >= finalScore) {
clearInterval(interval);
}
}, 1000);
}
function animate() {
}