forked from swapnilsparsh/30DaysOfJavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (24 loc) · 846 Bytes
/
Copy pathscript.js
File metadata and controls
29 lines (24 loc) · 846 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
document.addEventListener('DOMContentLoaded', () =>{
const timeLeftDisplay = document.querySelector('#time-left')
const startBtn = document.querySelector('#start-button')
const resetBtn = document.querySelector('#reset-button')
timeLeft = 10
function countDown(){
setInterval(function(){
if(timeLeft <= 0) {
clearInterval(timeLeft = 0)
}
timeLeftDisplay.innerHTML = timeLeft
timeLeft = timeLeft - 1
}, 1000)
}
// function resetCount(){
// if(timeLeft = 0) {
// countDown()
// }
// timeLeftDisplay.innerHTML = timeLeft
// timeLeft = timeLeft - 1
// }
startBtn.addEventListener('click', countDown)
// resetBtn.addEventListener('click', resetCount)
})