Question: Having trouble with making the buttons work. Please help Timer: 01:00 Start Stop Reset var timer = duration, minutes, seconds; function startTimer(duration, display) { setInterval(function
Having trouble with making the buttons work. Please help
var timer = duration, minutes, seconds;
function startTimer(duration, display) {
setInterval(function () {
minutes = parseInt(timer / 60, 10)
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = minutes + ":" + seconds;
if (--timer < 0) {
timer = duration;
}
}, 1000);
}
window.onload = function () {
var oneMinutes = 60 * 1,
display = document.querySelector('#time');
startTimer(oneMinutes, display);
};
function stopTimer() {
timer.terminate();
timer= undefined;
}
resetTimer(){
//not sure
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
