Question on push.mutualFollowers

Hi and thanks for your answer, but I have a question on that. I am using push.mutualFollowers but it prints out outer array by inner array in this case 5 X 3 to get one answer( or 15 answers but only one name. ( John being common In both).
I’m not understanding, or I’m vague why it does this.

Is this what you have a question about?

console.log('Both are friends with: ' + mutualFollowers.push(bobsFollowers[i]))
string concat string

Only the second part is not a string, but a number, the length of the mutualFollowers array. Read up on the .push() method and you will learn that it returns a new length.

To concatenate with the string value,

mutualFollowers.push(bobsFollowers[i]) // do this first
console.log('Both are friends with: ' + bobsFollowers[i])

I mtf thanks for answering me, I believe it was the second one, I was also not expecting an answer. apologies for the long wait.

1 Like