Javascript Repeat a String
This can be done using the .repeat() method:
"abc".repeat(3);
Output
"abcabcabc"
"abc".repeat(0);
Output
""
"abc".repeat(-1);
Output
Throws a RangeError
In the general case, this should be done using a correct polyfill for the ES6 String.prototype.repeat() method.
Otherwise, the idiom new Array(n + 1).join(myString) can repeat n times the string myString:
var myString = "abc";
var n = 3;
new Array(n + 1).join(myString);
Output
"abcabcabc"