Repeat a string: Difference between revisions

m
→‎{{header|JavaScript}}: more precise wording
(added ocaml)
m (→‎{{header|JavaScript}}: more precise wording)
Line 24:
}</lang>
=={{header|JavaScript}}==
This solution creates an empty array of size n+1 andnull elements, then joins itthem using the target string as the delimiter
<lang javascript>String.prototype.repeat = function(n) {
return new Array(1 + parseInt(n, 10)).join(this);
Anonymous user