cancel
Showing results for 
Search instead for 
Did you mean: 

Add Leading Zeros

dwhansen-cbg
Contributor

I have strings that are storing a two digit number (i.e. 00, 01, 02, etc) but I need to add another leading zero (i.e. 000, 001, 002). I don’t want to simply concatenate a 0 on the front in case I have values that end up being three digits.

1 ACCEPTED SOLUTION

dwhansen-cbg
Contributor

Thank you @tstack! That worked!

View solution in original post

10 REPLIES 10

evanhk
New Contributor II

(“0” + $value).slice(-3)

.slice(-3) will take the last 3 characters in the string