Created
May 30, 2017 16:18
-
-
Save ar2zee/c54d5acc63a718c25e9a5737943d1266 to your computer and use it in GitHub Desktop.
example of map function with array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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