Nested Loop Lesson 6

I can’t find any problem with my code. Can you? Please help!

// Write your code below
const bobsFollowers = ['Frank', 'John', 'Suzie', 'Bob'];
const tinasFollowers = ['Jackie', 'Bob', 'Suzie'];
const mutualFollowers = [];

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

console.log(mutualFollowers);

Nested Loop

Small mistake, easy to glaze over when staring at code for a while! it should be tinasFollowers.length, that should solve your issue.

2 Likes

Thanks for your help