Created
June 1, 2019 04:20
-
-
Save rtviner/34478fcea668c4b83bff77a1806ee302 to your computer and use it in GitHub Desktop.
countdown timer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countdown (minutes) { | |
for (let seconds = minutes * 60 ; seconds >= 0; seconds--) { | |
setTimeout(() => tick(seconds), 1000); | |
} | |
function tick (seconds) { | |
let secondsView = ((seconds%60) >= 10) ? seconds%60 : `0${seconds%60}`; | |
console.log(`${Math.floor(seconds/60)||"00"}:${secondsView||"00"}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
function countdown (minutes) {
}