'ni'.repeat(3);
String.prototype.repeatString1 = function (n) { return Array(n + 1).join(this); } console.log('ni'.repeatString1(3));
String.prototype.repeatString2 = function (n) { return Array(n).fill(this).join(''); } console.log('ni'.repeatString2(3));
|