Skip to content

Instantly share code, notes, and snippets.

@funador
Last active August 2, 2018 21:27
Show Gist options
  • Save funador/1a2d4a8c933c7e4373cd183cdb65dcec to your computer and use it in GitHub Desktop.
Save funador/1a2d4a8c933c7e4373cd183cdb65dcec to your computer and use it in GitHub Desktop.
const dogs = [
{name: 'Snookums', needsShots: true, breed: 'pug', age: 2},
{name: 'Thor', needsShots: true, breed: 'hound', age: 1},
{name: 'Wunderbar', needsShots: false, breed: 'pug', age: 9},
]
// We are going to create a new array of our vet approved dogs!
const vetApprovedDogs = dogs.myMap((dog) => {
// The vet makes his approval
dog.needsShots = false
// What ever gets returned ends up at the same index
// in the new array.
return dog
})
console.log(vetApprovedDogs) // everyone has their shots!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment