Created
March 23, 2018 22:29
-
-
Save andylshort/6f9f42ee7877fe618b95ece0a1d95899 to your computer and use it in GitHub Desktop.
The infamous left pad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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