Created
March 11, 2023 10:47
-
-
Save Risyandi/53138f76b1ddf714609a50e73b5f8dad to your computer and use it in GitHub Desktop.
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
// Set initial countdown time to 60 seconds | |
var countdown = 60; | |
// Update the timer display every second | |
setInterval(function() { | |
countdown--; | |
var seconds = countdown % 60; | |
var minutes = Math.floor(countdown / 60); | |
// Add leading zero to seconds if less than 10 | |
if (seconds < 10) { | |
seconds = "0" + seconds; | |
} | |
// Format the timer display string | |
var timerDisplay = minutes + ":" + seconds; | |
// Update the timer display element on the page | |
document.getElementById("timer").innerHTML = timerDisplay; | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment