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

6 lines
134 B
JavaScript
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
String.prototype.repeat = function(n) {
return new Array(1 + (n || 0)).join(this);
}
console.log("ha".repeat(5)); // hahahahaha