+ 2
// initial timer
let s1 = 14;
let s2 = 59;
timer.innerText =
s1.toString()
.padStart(2,0)
+ ":" +
s2.toString()
.padStart(2,0);
// countdown
const countDown = () => {
s2--;
s2 = s2<0 ? 59 : s2;
s2 <= 0 && s1--;
timer.innerText =
s1.toString()
.padStart(2,0)
+ ":" +
s2.toString()
.padStart(2,0);
if(s1 <= 0){
negativeMsg();
stopInterval();
}
}
countDown();
// time interval
const interval =
setInterval(countDown, 10)
// stop time interval
const stopInterval = () => {
clearInterval(interval)
}