Add basic countdown timer
jasonlong opened this issue · 2 comments
jasonlong commented
Find a npm module for handling the countdown. Hardcoding 25 minutes is fine for now.
vldmkrsh commented
let countdownTimer = (minutes, renderCountdown, timeout) => {
'use strict'
let secondInJavaScript = 1000
let secondsInOneMinute = 60
var countdown = minutes * secondsInOneMinute
renderCountdown(countdown)
let timer = setInterval(() => {
countdown -= 1
if (countdown === 0) {
clearInterval(timer)
timeout()
} else {
renderCountdown(countdown)
}
}, secondInJavaScript)
}
countdownTimer(1, console.log, () => { console.log('timeout') })
/*
* P.S. You're welcome.
*/