Skip to content

Instantly share code, notes, and snippets.

@andylshort
Created March 23, 2018 22:29
Show Gist options
  • Save andylshort/6f9f42ee7877fe618b95ece0a1d95899 to your computer and use it in GitHub Desktop.
Save andylshort/6f9f42ee7877fe618b95ece0a1d95899 to your computer and use it in GitHub Desktop.
The infamous left pad
if (!String.prototype.padLeft) {
String.prototype.padLeft = function(c, size) {
var s = this.valueOf();
while (s.length < size) s = c + s;
return s;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment