Skip to content

Instantly share code, notes, and snippets.

@ricardoriogo
Created June 29, 2015 17:02
Show Gist options
  • Save ricardoriogo/e90e7eb9e73cab8c3c14 to your computer and use it in GitHub Desktop.
Save ricardoriogo/e90e7eb9e73cab8c3c14 to your computer and use it in GitHub Desktop.
Pad string
function pad(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment