Added it to a JSfiddle here, padon the appearance but i couldn’t be bother to set up image hosting when it’s not really needed for this issue.
The timer will start once the first tile is clicked, the reset button works to reset the whole game and the submit/leaderboard is just for show.
Any insight on what’s happening here would be awesome!
I think I get what is happening. You are removing and re-adding the
setInterval every time you flip a card. So a method is called every second (if you don’t flip a card). But what happens if you flip a card when half a second has passed after the last call to that method? It will reset the interval and wait a second, but it should have waited half a second. So the time you measured is “delayed” by on average half a second (each time it is delayed by a value ranging between 0 and 1 second).
Cheers, that was helpful!
Ended up creating a new function for starting the timer that checks if the timer is already running and if not, starts it up. No more
clearInterval on a card click.
All worked fine after that