I want my timer to stop and reload to 0 when it hits 25 with a clearInterval
but it says that the variable refreshInterval
is undefined
. The timer resets but it keeps on going and I want it completely to stop until its enabled again.
function removeMe() {
var refreshInterval = setInterval(setTime, 1000);
display.removeBen();
totalSeconds = 0;
};
//timer1//
var minutesLabel = document.getElementById("minutes");
var secondsLabel = document.getElementById("seconds");
var totalSeconds = 0;
function setTime() {
if (totalSeconds == 1) {
game.clickValue + 2;
}
if (totalSeconds == 25) {
game.clickValue - 2;
clearInterval(refreshInterval);
totalSeconds = 0;
} else
++totalSeconds;
secondsLabel.innerHTML = pad(totalSeconds % 60);
minutesLabel.innerHTML = pad(parseInt(totalSeconds / 60));
}
function pad(val) {
var valString = val + "";
if (valString.length < 2) {
return "0" + valString;
} else {
return valString;
}
}
//timer1//