In C# whenever I wanted to print two digit numbers I’ve used
int digit=1;
Console.Write(digit.ToString("00"));
How can I do the same action in Javascript ?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
c#
digit.toString("00")appends one zero to the left ofdigit(left padding). In javascript I use this functon for that:You can also rewrite it as an extention to Number:
[edit oct. 2021]
A static es20xx
Numbermethod, also suitable for negative numbers.