Nested Loops Can't figure out why code isn't working

Hello, I’ve already altered my code many times by looking at other people but what exactly did I do wrong. I hope it’s not a small mistake like a missed bracket.

let bobsFollowers = ["Joe", "Mj", "Aj", "Bj"];
let tinasFollowers = ["Mj", "Aj", "Emy"];
let mutualFollowers = [];
for (let i = 0; i < bobsFollowers.length; i++) {
  for (let j = 0; i < tinasFollowers.length; j++) {
    if (bobsFollowers[i] === tinasFollowers[j]) {
console.log(Our mutual followers are: ${mutualFollowers})
1 Like

It’s a small issue, but at least it’s not a missed bracket :wink:
You have:
let j = 0; i < tinasFollowers.length; j++
You need:
let j = 0; j < tinasFollowers.length; j++
See the i vs. j typo?


I’ve done this more times than I can count.
Something that helped me was naming my variables something that made sense to me. As I wrote more loops, it became easier to use the i and j variable names!

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