Trouble with "Repeat a string repeat a string" challenge

Tell us what’s happening:
So I’m working on the repeat a string challenge. I’m a noob, so apologies in advance if I have a tough time conveying my intentions.

I split the string into an array, with the hope of joining it back into a string once I had concatenated the array to itself the correct number of times.

I first tried using a for loop (the commented out section), but that only concatenated it once as long as num was less than i, which makes sense to me after I thought through it.

Then I took a similar approach with a while loop, but that returns nothing when I run it.

I’ve also tried using .push in place .concat, but that just returns a number, which also is a mystery to me, but I’m trying to do one thing at a time at the moment.

If anyone could point me in the right direction, I’d greatly appreciate it. Thanks!

Your code so far

function repeatStringNumTimes(str, num) {
  var splitStr = str.split();
  var allSplit = splitStr;
  var joinMe = [];
 
  var i=0;
   while (i < num){
     allSplit.concat(splitStr);
     i++;
   }
  
  
//   for (var i=0; i < num ; i++)
//    if (i <= num);
//      {joinMe = allSplit.concat(splitStr);}

   if (num <= 0) {
    return "";
  }
   else return (
     joinMe.join("") 
   );

 
}

repeatStringNumTimes("abc", 5);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:59.0) Gecko/20100101 Firefox/59.0.

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

OK, two big problems, one small one.

  1. First of all, you return joinMe, but you never actually did anything with it. You should be returning allSplit.

  2. When you concat, it doesn’t change the original, but returns the new string. You always have to check with these methods if they change the original and what they return. You need:

allSplit = allSplit.concat(splitStr);
  1. It should work after that. But as a quibble, you don’t need to split and join the strings.

Oops. I must’ve has tunnel vision last night, cause that’s pretty obvious on a second look. Thanks for taking the time out!