Last active
March 8, 2017 12:54
-
-
Save Alex1990/f269bf544f46614215410a45bc885f88 to your computer and use it in GitHub Desktop.
Repeat the specified string with n times.
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
if (typeof String.prototype.repeat !== function) { | |
Object.defineProperty(String.prototype, 'repeat', { | |
configurable: true, | |
enumerable: false, | |
writable: true, | |
value: function (n) { | |
let result = ''; | |
while (n--) { | |
result += this; | |
} | |
return result; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment