Repeat a string repeat a string 1

Repeat a string repeat a string 1
0.0 0

#1

Tell us what’s happening:

Your code so far

function repeatStringNumTimes(str, num) {
  // repeat after me
  var output= " ";
  for(var i =0; i<num; i++){
    
    output += str;
  }
  return output;
}

repeatStringNumTimes("abc", 3);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.

Link to the challenge:

What is the error in this code? Please guide me for the algorithms of FreeCodeCamo as It seems very challenging for me. Thanks


#2

The function’s output always have a space at the beginning. The output should start as an empty string.