Hi!
const bobsFollowers = ['Jane', 'Izumi', 'Sasha', 'Natsu'];
const tinasFollowers = ['Haru', 'Izumi', 'Natsu'];
const mutualFollowers = [];
for(var i=0; i<bobsFollowers.length; i++){
for(var j=0; j<tinasFollowers.length; j++){
if(bobsFollowers[i] === tinasFollowers[j]){
mutualFollowers.push(bobsFollowers[i]);
console.log('i and j are ' + bobsFollowers[i]);
console.log('The mutual Followers are ' + mutualFollowers);
console.log('The last mutual Follower is ' + mutualFollowers[mutualFollowers.length-1]);
}
else{
console.log('i is '+ bobsFollowers[i]+ ' and j is '+ tinasFollowers[j]);
}
}
}
Is there a way to get the value of an array index without using this trick?
console.log('The last mutual Follower is ' + mutualFollowers[mutualFollowers.length-1]);
Thank you!