How can I include double digits in my pomodoro clock?

How can I include double digits in my pomodoro clock?
0

#1

my clock counts down like this:
10
9
8…

How can I have it count down like this:
10
09
08
07…?


#2

Where ever you specify counter in your code, call a function (i.e. leadingZero or what ever you want to call it) with counter as the parameter value. This function should return a ‘0’ on the front of the number if it less than 10 or just return the number if it is not less than 10.

FYI - Your timer is not working correctly. There is a 2 second delay before it starts changing the display and when it does, it shows only 1 second less than the original counter. One second after the Start button is clicked, you should see 4:59, but it takes 2 iterations, because during the first duration counter = -1, then it gets reset to 60, so on the second iteration, counter becomes 59.


#3

You actually don’t need to write your own function — JS now has its own (padStart), though it’s not IE-compatible so you might still want to write your own.


#4

thank you, I got everything fixed now