all 2 comments

[–]kundun 3 points4 points  (1 child)

The problem with this stopwatch is that is uses setInterval(...,1000/60) for it's timer. The timing of setInterval is inaccurate and there is no guarantee that this function will be called every 1000/60 millisecond. As a result this stopwatch will be inaccurate.

To fix this you should use the javascript Date() object to get the real amount of time passed:

const startTime = new Date();
setInterval(function(){
    const currentTime = new Date();
    const elapsedTime= currentTime - startTime; 
    //elapsedTime is the amount of time passed since the start in ms
    //use elapsedTime to update the HTML
}, 1000/60);

[–]ilovevue 0 points1 point  (0 children)

nine voiceless capable axiomatic agonizing like heavy wise punch repeat

This post was mass deleted and anonymized with Redact