Posts Tagged ‘zero_padding’

Javascript: zero padding numbers

April 24, 2010 2 comments

There are many ways to accomplish this in js but the following is the one I found to be the best: Let’s say you need to pad a number with leading zeros so the total digits of the number will be 5, simply do a


n is the number to be padded.

[ credit goes to ]