Repeat String - Javascript

Posted by brad on Stack Overflow See other posts from Stack Overflow or by brad
Published on 2008-10-14T20:10:18Z Indexed on 2010/03/12 14:37 UTC
Read the original article Hit count: 261

Filed under:
|

What is the best or most concise method for returning a string repeated an arbitrary amount of times?

The following is my best shot so far:

function repeat(s, n){
    var a = [];
    while(a.length < n){
        a.push(s);
    }
    return a.join('');
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about string