Skip to content

Instantly share code, notes, and snippets.

@sebnilsson
Created April 5, 2013 14:25
Show Gist options
  • Save sebnilsson/5319669 to your computer and use it in GitHub Desktop.
Save sebnilsson/5319669 to your computer and use it in GitHub Desktop.
Add padLeft to string prototype
String.prototype.padLeft = function (len, c) {
var s = this;
c = c || '0';
while (s.length < len) {
s = c + s;
}
return s;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment