Nested Loops 6/10


#1

I’m stuck!

// Write your code below

const bobsFollowers = [‘Henk’, ‘Wim’, ‘Piet’, ‘Klaas’];
const tinasFollowers = [‘John’, ‘Wim’, ‘Piet’];
const mutualFollowers = []
for (let i = 0; i < bobsFollowers.length; i++) {
for (let j = 0; j < tinasFollowers.length; j++) {
if (bobsFollowers[i] === tinasFollowers[j]) {
mutualFollowers.push(‘tinasFollowers[j]’);
}
}
}

gives

Your mutualFollowers array should hold the two elements which exist in both bobsFollowers and tinasFollowers


#2

if you log mutualFollowers what do you see ?


#3

At line 9 of your code: mutualFollowers.push(‘tinasFollowers[j]’);.
What you’re doing is passing a string ‘tinasFollowers[j]’ and not the value of it.
You need to remove the quotes. mutualFollowers.push(tinasFollowers[j]);


#4

You’re a hero! Thank you