100-project-100-days-website/100_projects/33-create-countdown-timer/main.js
2023-03-26 01:08:23 +03:00
Ask

27 lines
617 B
JavaScript

{1e39a8ef0364ef625348002c6ffba429412a7af4 true 617 main.js 0xc001f28c40}

var seconds = 119,
countDiv = document.getElementById('countdown'),
secondPass,
countDown = setInterval(function(){
"use strict";
secondPass();
},1000);s
function secondPass(){
"use strict";
var minutes = Math.floor(seconds / 60),
remSeconds = seconds % 60;
if (seconds < 10){
remSeconds = "0" + remSeconds;
}
countDiv.innerHTML = minutes + ":" + remSeconds;
if (seconds > 0){
seconds = seconds - 1;
} else {
clearInterval(countDown);
countDiv.innerHTML = "Done!!";
}};