Repeat a string
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
Take a string and repeat it some number of times. Example: repeat("ha", 5) => "hahahahaha"
JavaScript
This solution creates an empty array of size n+1 and then joins it using the target string as the delimiter <lang javascript>String.prototype.repeat = function(n) {
return new Array(1 + parseInt(n, 10)).join(this);
}
alert("ha".repeat(5)); // hahahahaha</lang>
Ruby
<lang ruby>"ha" * 5 # ==> "hahahahaha"</lang>
Tcl
<lang tcl>string repeat ha 5 ;# => hahahahaha</lang>