Repeat a string repeat a string - Range Error

Tell us what’s happening:
Can someone explain the difference between my code and the basic solution? When i run mine it gives me a range error for “invalid count value.”

The only difference between mine and the basic solution is the fact i created a variable to store the string outside the if statement, but the statement calls the same variable so i’m confused why it wouldn’t work.

Appreciate any insight.

Your code so far

  var repeat = str.repeat(num);
  if (num > 0) {
  return repeat;
    return "";  

repeatStringNumTimes("abc", -2);```
**Your browser information:**

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

**Link to the challenge:**