[typo] Nested loops

My code for this exercise is below. I get to step 4 of creating the Nested Loop and I keep getting the error message “Did you accidentally delete your bobsFollowers array?” I haven’t deleted the array or touched it since I first created it in step 1. When I check it against the solution code, it seems to be the same. Am I missing something here?

let bobsFollowers = ['Linda', 'Louise', 'Gene', 'Teddy'];
let tinasFollowers = ['Louise', 'Gene', 'Jimmy Jr.'];
let mutualFollowers = [];

for (let i = 0; i < bobsFollowers.length; i++) {
  for (let j = 0; j < tinasFollowers.length; j++){
    if(bobsFollowers[i] === tinasFollowers[j]){
      return mutualFollowers.push(bobsFollowers[i]);
    }
  }
};

what i find confusing is the lack of output, you should get this error:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_return_or_yield

Does that mean my code is incorrect? It seemed(to me at least) to match the solution code. Any feedback on the code is helpful!

As far as not being error-free, yes it is incorrect. We cannot use return outside of a function. Remove that keyword and save/run.

1 Like