How to Format Numbers by Prepending 0 to single-digit numbers in Javascript
If you have a single-digit number, and you need to format it to always have at-least two digits, then you can use the below function to solve your problem:
When testing the above method, you could do the following:
This is especially useful where you need to format dates: