Nested loops, help in the console log

Hi everyone, who can help me please figuring out why in the console log it says 1 and then Marco, and then 2 and Marco, Tobia?
I expected just to show me in the console only the 2 common friends which are Marco and Tobia and nothing else, why numbers? and why Marco is at the top separated?

https://www.codecademy.com/courses/introduction-to-javascript/lessons/loops/exercises/for-loops-iii

Thanks a lot for the help!

You are logging the output of .push(), which returns the new length of the array. Remove your .push() call from the console.log() on line 12 (you can just remove the log statement altogether) to eliminate the numbers from the output.

To remove “Marco” at the top, move the console.log() call on line 14 out of the for loops: By leaving it inside, you output the contents of mutualFollowers each time the loop runs (so, given a longer list of mutual followers, you’d see Marco, then Marco and Tobia, then those two plus whatever else is on that list).

2 Likes

Thanks a lot, I really appreciated your help!