Good results bad tests

Tell us what’s happening:
Hello all, I have created the function, the results are right but can’t pass the test, even if the results are rigth. What I am doing wrong? Thanks in advance.

  **Your code so far**

function repeatStringNumTimes(str, num) {
  result = "";
  for(let i = 0; i<num ; i++) result += str; 
   return result;

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/91.0.4472.77 Safari/537.36

Challenge: Repeat a String Repeat a String

Link to the challenge:

Bad code. Declaring variables not only good, but required.

Hi !

You should be getting some sort of error message in the console.

When you make that simple change then it passes

you’re right, that was it, thanks!

Thanks for your response, it was the missing variable declarations.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.