Created
March 31, 2009 21:16
-
-
Save alassek/88411 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
String.prototype.padLeft = function(length, s) { | |
var pad = []; | |
var padding = length - this.length; | |
if (padding > 0) { | |
for (i = 0; i < padding; i++) pad.push(s); | |
return pad.join('') + this; | |
} | |
return this + ''; | |
} | |
String.prototype.padRight = function(length, s) { | |
var pad = []; | |
var padding = length - this.length; | |
if (padding > 0) { | |
for (i = 0; i < padding; i++) pad.push(s); | |
return this + pad.join(''); | |
} | |
return this + ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment