Repeat a string repeat a string (Ananya)

Repeat a string repeat a string (Ananya)
0

#1

Tell us what’s happening:
I have written this code and all the criterias given below meet exactly. Can someone tell where I’m going wrong?

Your code so far

function repeatStringNumTimes(str, num) {
  if (num<=0) {
    return "";
  } else {
  for (i=1; i<=num; i++) {
    arr.push(str);
  }
  
  return arr.join("");
}}

repeatStringNumTimes("*", 8);

Your browser information:

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

Link to the challenge:


#2

If you look in the FCC console, you will see the error message:

ReferenceError: arr is not defined

You are pushing to arr, but never declared what arr is. Take a look back at the following challenge, to get a hint at what to do here.