Pomodoro project - timer doesn't always start counting down from 59 seconds

Pomodoro project - timer doesn't always start counting down from 59 seconds
0

#1

Hello,
Wondering if anybody could help me figure out why - when the timer starts - the countdown`s seconds doesn’t start at 59. Instead, it starts at 58.

Here’s the project so far - it is far from finished as you can see! Thanks in advance :nerd_face:


#2

Put a console.log(distance); under the following line and watch the first couple of values. When I tested your app, I had the following results:

var distance = dTime - now; //in milliseconds!
console.log(distance)

Thu Dec 14 2017 12:14:22 GMT-0800 (Pacific Standard Time)
58991
0 mins, 58 secs.
57991
0 mins, 57 secs.
56988
0 mins, 56 secs.
56000
0 mins, 56 secs.
54999
0 mins, 54 secs.

That first distance is 58.991 seconds, which is much closer to 59 than 58, but since your code uses Math.floor, it will return 58.


#3

Thank you, that helps!