Repeat a string repeat a string(while loop problem)

Repeat a string repeat a string(while loop problem)
0.0 0

#1

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:


#2

Look carefully at the value your function returns.


#3

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


#4

It happens to everyone at some point.