Last active
August 29, 2015 14:10
-
-
Save basselin/7c68332ee74293b87ba7 to your computer and use it in GitHub Desktop.
Format number with 2 digit "05" in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nbr = 5; | |
var nbr0X = ("0" + nbr).slice(-2); // "05" | |
var nbr = 4.56789; | |
var nbrX00 = nbr.toFixed(2); // 4.57 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment