Repeat a string: Difference between revisions
→{{header|JavaScript}}
Line 727:
console.log("ha".repeat(5)); // hahahahaha</lang>
For larger numbers of repetitions, however, it proves significantly faster to progressively double a copy of the original string (concatenating it with itself)
See the technique of 'Egyptian Multiplication' described in the Rhind Mathematical Papyrus at the British Museum.
|