http://jsfiddle.net/vvccvvcc/mu45bptk/
how do I pause the timer? I want it to stop when it gets to 5 seconds
I tried this as seen in the fiddle
else {
isWaiting = true;
seconds--;
if (seconds == 5) {
seconds=seconds;}
}
does not work
The timer is initialized by
setInterval(GameTimer, 1000);
You will need to clear the interval in order to stop calling the function. Alternatively if you don't want to clear the interval you can say
The way you've written it,
second
is decreased regardless of the condition (since it's before theif
statement) and therefore,second = second
becomes irrelevant.