Answers for "map a keys from an array in a separate arraylist javascript"

0

map a keys from an array in a separate arraylist javascript

const myUsers = [
    { name: 'shark', likes: 'ocean' },
    { name: 'turtle', likes: 'pond' },
    { name: 'otter', likes: 'fish biscuits' }
]

const usersByLikes = myUsers.map(item => {
    const container = {};

    container[item.name] = item.likes;
    container.age = item.name.length * 10;

    return container;
})

console.log(usersByLikes);
Posted by: Guest on October-22-2020

Code answers related to "map a keys from an array in a separate arraylist javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language