Closed alpha2262 closed 8 years ago
second issue: you need to clear the timeout when you click, using clearTimeout
You could also detect whether there's already a timer. On click, before you setTimeout
or setInterval
, check whether timerIsAlreadyRunning == false
, and only set the timer if it's false. Then, after setting the timer, timerIsAlreadyRunning = true
.
In pseudocode:
set timerIsAlreadyRunning to false
on click
if timerIsAlreadyRunning is false, then
setTimeout
set timerIsAlreadyRunning to true
otherwise do nothing
I tried jquery to update html on page. First issue: I expected minutes and seconds time elapse to appear to happen. No content displayed happened instead.
Second issue: the timer appears to be counting faster with each successive click, which I recall discussing as an issue in class but can't remember how to fix. Timer is accumulating time faster than second intervals is happening instead.
My repo link is https://github.com/alpha2262/concentration/blob/silver/javascript.js and my question is about lines 72 - 88.