Last active
May 4, 2016 09:00
-
-
Save DStereo/adb5b7d8a77f3b47ee1010b0d1d879bc to your computer and use it in GitHub Desktop.
Repeat string in prototypal manner
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.repeat !== 'function') { | |
String.prototype.repeat = function(times) { | |
if (typeof times !== 'number') { | |
return this; | |
} | |
return Array(times + 1).join(this); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment