Repeat a String Repeat a String Sorry help again

My head is exploding with stress. I got the code to it should be right. idk take a look.

Your code so far


function repeatStringNumTimes(str, num) {
  // repeat after me
  Alpha = '';
  while (str = num > 0) {
    Alpha = + str; num--;
     
  }
 return Alpha;
}

repeatStringNumTimes("abc", 3);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string

I am unsure why you are doing this:

while (str = num > 0) {

This is assigning true or false to str, so then if this wasn’t incorrect syntax

Alpha = + str;

Because I assume you meant

Alpha += str

This is saying

Alpha += true

Or

Alpha += false

neither of which are valid things

Perhaps, the biggest tip I can give you is to add console.log statements to your code when you’re trying to debug.

Dealing with the problem at hand, your while statement should just test n like so: while (n > 0)
and string concatenation uses the += operator.
Also it’s a good idea to assign Alpha to a local variable using either let or var. Choose let.

Keep on truckin’

Let me break down this challenge.

str is the string you want to repeat
num is, however, many times you want to repeat it.

Your Alpha variable is correct, but you need to declare it using var or let on only the first instance. I suggest using better class names that are lower case.

I also suggest using a for loop:

for (var i = 0; i < num; i++) {
  // code to add to string (Alpha) goes here
}

You are close, but your while loop condition makes no sense

str = num > 0

I have no idea what str = is supposed to be doing.

Anyways,

Alpha = + str; num---

Each piece of code should be on its own line.
It would be Alpha += str; which means Alpha = Alpha + str

You are getting better from what I have seen. I struggled a lot with the first challenges, but I improved after doing research and learning the code logic.

Just break down your challenge better to see what your goals are. If your code doesn’t logically make sense (Like str = num > 0) then it probably isn’t correct.

Make comments to show what your code is doing.