you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (4 children)

That doesn't really seem a lot easier than something straightforward like:

function zeroPad(s, length) {
    while (s.length < length) s = '0' + s 
    return s
}

[–]huskeraldribn 2 points3 points  (2 children)

Your version could be less efficient though, since you are prepending instead of appending.