0
I want that in my watch always appear in two digits.
I want in my JavaScript watch digits always appear in two digits even 1-9 appear as 01-09 but problems in my code that I didn't detect yet. Anyone help me to solve my problem. https://code.sololearn.com/WR2WN90W67S8/?ref=app
1 ответ
+ 3
Well you may need to avoid hard-coding the rules at line 46 to 49 and what you need is padding. 😉
For example,
var answer = 42;
alert(
answer
.toString()
.padStart(3, '0')
); // display as 042
You may learn more info @ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart