block by aemkei 1180489

Leading Zeros - 140byt.es

Leading Zeros - 140byt.es

Pad a given number with leading zeroes. Useful to make it a fixed width like with e.g. sprintf in other programming langages.

Usage

pad(number, count);
// returns number with leading zeros

For more information

See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter. And check my “JavaScript Golf Lessons“ slides.

index.js

LICENSE.txt

annotated.js

package.json

test.html