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

6 lines
134 B
JavaScript
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
String.prototype.repeat = function(n) {
return new Array(1 + (n || 0)).join(this);
}
console.log("ha".repeat(5)); // hahahahaha