Last active
August 29, 2015 14:26
-
-
Save SeeThruHead/9d7021d017c6aef302e5 to your computer and use it in GitHub Desktop.
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
String.prototype.repeatify = function(x) { | |
// Array.apply(null, {length: x}) creates an array of undefined values with length x | |
return Array.apply(null, {length: x}).map(() => this).join(''); | |
}; | |
// or a better but less fun solution | |
String.prototype.repeatify = function(x) { | |
return Array(x + 1).join(this); | |
}; | |
console.log('hi'.repeatify(10)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment