Last active
August 29, 2015 14:04
-
-
Save bruslim/1e4d00e55ce32b8f3e3b to your computer and use it in GitHub Desktop.
String.prototype.repeat Shim
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
// Repeat Shim | |
String.prototype.repeat = String.prototype.repeat || function(count) { | |
// temporary return array | |
var ret = []; | |
// count to count | |
for(var i = 0; i < count; i++) { | |
// push this (the string we want to repeat) | |
// into the array | |
ret.push(this); | |
} | |
// use Array.prototype.join to concat | |
// all the string together. | |
return ret.join(''); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment