Created
February 3, 2022 18:16
-
-
Save queviva/c737dba9f79203c0e00fe04a4e18f83d to your computer and use it in GitHub Desktop.
front pads number with zero
This file contains hidden or 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
('00000' + n).slice(-3) |
comparing lengths for the most common usage
('000'+n).slice(-3),
(''+n).padStart(3,'0')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
put as many zeros as necessary, and set the slice to negative-whatever