Repeat the string 7

Tell us what’s happening:
i dont get it but why…

Your code so far


function repeatStringNumTimes(str, num) {
var accumulatedStr = " ";

while ( num > 0) {
  accumulatedStr += str;
  num--;
}
return accumulatedStr;
}

repeatStringNumTimes("abc", 3);

Your browser information:

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

Challenge: Repeat a String Repeat a String

Link to the challenge:

Hey there @shrini,

What do you not get? You have to be more specific with what you are having problems with so we can try and help you.

I type the code according to the instruction but still i dint get

It looks like you start with whitespace rather then empty string

1 Like

As @snigo said, you started with a whitespace in your string. What this will do, is add a whitespace at the beginning of every string you return. Here’s what it looks like:

thank you so much i got it correct .