Last active
July 20, 2018 05:30
-
-
Save abhi9bakshi/039bb1af33d4249a6c0f1491d52cb11c to your computer and use it in GitHub Desktop.
Simple Javascript countdown timer
This file contains hidden or 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
// index.html | |
<p id="timer"> | |
00:00:00 | |
</p> | |
// script.js | |
let count = 0; | |
let intervalRef = null; | |
intervalRef = setInterval(_ => { | |
count+=10; | |
let ms = count % 1000; | |
let s = Math.floor((count / 1000)) % 60; | |
let m = Math.floor((count / 60000)) % 60; | |
$('#timer').text(m + ":" + s + ":" + ms); | |
}, 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment