Last active
September 27, 2015 20:43
-
-
Save qetr1ck-op/df77c34e3efec24039e6 to your computer and use it in GitHub Desktop.
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
/* | |
1. create method in string prototype | |
2. it should return multiple repeated string by n times | |
consle.log( "foo".repeat(3) ); // 'foofoofoo' | |
*/ | |
String.prototype.repeat = function(times) { //or use built-in ES6 repeat() | |
return new Array(times + 1).join(this); | |
}; | |
consle.log( "foo".repeat(3) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment