D
Size: a a a
D
D
D
D
D
const mates = [{
name: 'Alex',
age: 13
},
{
name: 'Oleg',
age: 14
},
{
name: 'Anna',
age: 12
},
]
const matesWithFriends = mates.map(mate => {
const friends = mates.filter(otherMate => otherMate.name !== mate.name).map(friend => friend.name)
return {...mate, friends}
})
console.log(matesWithFriends)
D
D
W
let updatedMates = mates.map(currentMate => (
{
...mate,
friends: mates
.map(friend => friend.name)
.filter(friend => friend !== currentMate.name)
}
))
D
D
D
D
W
W
W
D
D
D
D