Repeat String - Javascript

前端 未结 30 1817
长情又很酷
长情又很酷 2020-11-22 08:46

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          


        
30条回答
  •  隐瞒了意图╮
    2020-11-22 08:54

    Just another repeat function:

    function repeat(s, n) {
      var str = '';
      for (var i = 0; i < n; i++) {
        str += s;
      }
      return str;
    }
    

提交回复
热议问题