How can I include double digits in my pomodoro clock?

my clock counts down like this:

How can I have it count down like this:

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.

1 Like

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.

1 Like

thank you, I got everything fixed now