Nested Loops

Hello everyone! I am currently working on the Nested Loops lesson and I am having quite a bit of difficulty with my practice example that has you use Bob’s followers and Tina’s followers. Here is my current code:

const bobsFollowers = ['Sarah', 'Tom', 'Mike', 'Kara'];
const tinasFollowers = ['Kara', 'Jade', 'Tom'];
const mutualFollowers = [];

for (let i = 0; i < bobsFollowers.length; i++) {
  for (let o = 0; o < tinasFollowers.length; o ++) {
    if (bobsFollowers[i] === tinasFollowers[o]) {

And here is the message that I receive when I run the code:

Did you include a nested for -loop in your code? Ensure:

  • You use let or var for iterator variables in your loops.
  • For example: let i = 0 , instead of i = 0
  • bobsFollowers is in the outer loop
  • tinasFollowers is in the inner loop.
  • You append elements to mutualFollowers in the inner loop.

Any help would be much appreciated!!

~ Dee

I figured it out!

for (let o = 0; o < tinasFollowers.length; o ++) {

For that line I had a space between ‘o’ and ‘++’ :smiley: