RosettaCodeData/Task/Repeat-a-string/JavaScript/repeat-a-string.js

6 lines
121 B
JavaScript
Raw Normal View History

2013-04-10 23:57:08 -07:00
String.prototype.repeat = function(n) {
return new Array(1 + n).join(this);
}
alert("ha".repeat(5)); // hahahahaha