GlobeTownDevs / stopwatch

Stopping your watches
0 stars 1 forks source link

setInterval #4

Open tbtommyb opened 7 years ago

tbtommyb commented 7 years ago

You could make sub functions for the code in each of the comment headings, which would help split it up and you could reuse the bit that pads the numbers with '0's. Or you could use the .toISOString method to get the time as a string.

At first I thought that making the setInterval run every 10ms, even when you've paused the timer, is inefficient but actually it makes the rest of the code a lot simpler so I like it!

njsfield commented 7 years ago

Another advantage of creating a sub-function for the code inside the setInterval is you can test whether it correctly converts milliseconds to formatted time. And you can pass it in 3600001 millseconds to check that it doesn't display about 60 minutes