Return to Snippet

Revision: 22353
at January 10, 2010 18:02 by edektor


Initial Code
String.prototype.pad = function(l, s){
	return (l -= this.length) > 0
        ? (s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, s.length) + this + s.substr(0, l - s.length)
        : this;
};

Initial URL

                                

Initial Description
pads a string "2".pad(2, "0"); //02

Initial Title
String.prototype.pad

Initial Tags
javascript

Initial Language
JavaScript