Skip to content

Instantly share code, notes, and snippets.

@d-simon
Created March 7, 2014 00:42
Show Gist options
  • Select an option

  • Save d-simon/9402826 to your computer and use it in GitHub Desktop.

Select an option

Save d-simon/9402826 to your computer and use it in GitHub Desktop.
String Padding / Leading Zeros
function pad(n, width, z) {
z = z || '0';
n = n + '';
while (n.length < size) { n = z + n; }
return n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment