Repeat a string repeat a string(while loop problem)

Tell us what’s happening:

I am not sure why this is not printing. In my mind in every loop string should add to result. But it is only adding only one time.? Where is

Your code so far

function repeatStringNumTimes(str, num) {
  // repeat after me
  var result = "";
  var count = 0;
  while(count < num){
    result += str;
    count++;
  }
  return str;
}

repeatStringNumTimes("abc", 5);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/repeat-a-string-repeat-a-string

Look carefully at the value your function returns.

1 Like

Omg. for good 3 hours I have been trying why is not working. Didn’t see it. thanks . Now I’m kinda embarrased :wink: