Found a simple one line solution:
("0000" + n).slice(-4)
If the string and padding are in variables, you would have:
mystr="45"
pad = '0000'
(pad + mystr).slice(-pad.length)
Answer found here, thanks to @dani-p.
Credits to @profitehlolz.
Found a simple one line solution:
("0000" + n).slice(-4)
If the string and padding are in variables, you would have:
mystr="45"
pad = '0000'
(pad + mystr).slice(-pad.length)
Answer found here, thanks to @dani-p.
Credits to @profitehlolz.