Skip to content

Instantly share code, notes, and snippets.

@ar2zee
Created May 30, 2017 16:18
Show Gist options
  • Save ar2zee/c54d5acc63a718c25e9a5737943d1266 to your computer and use it in GitHub Desktop.
Save ar2zee/c54d5acc63a718c25e9a5737943d1266 to your computer and use it in GitHub Desktop.
example of map function with array
var animals = [
{name : 'artur', food: 'fries'},
{name : 'sergey', food: 'fries'},
{name : 'anton', food: 'fries'},
{name : 'petya', food: 'fries'},
{name : 'oksana', food: 'fries'},
{name : 'lesya', food: ''},
{name : 'julya'},
{name : 'sasha', food: 'fries'}
];
// var names = animals.map(function(animal) {return animal.name + ' is a ' + animal.food; });
var names = animals.map((x) => x.name );
console.log(names);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment