when sameFriends = [];
'dick', 'rex', 'james' gets push in
when I added 'golf', //output remove james
How can I add push in the same element from aFriend and bFriend without removing any?
let aFriend = ['dick', 'rex', 'james', 'tom', 'jack'];
let bFriend = ['dick', 'rex', 'james', 'jake'];
let sameFriend = ['golf'];
for (let i = 0; i < aFriend.length; i++){
for (let k = 0; k < bFriend.length; k++){
if (aFriend[i] === bFriend[k]){
sameFriend.push(bFriend[k]);
console.log(sameFriend[k]);
}
}
}