-
-
Save RaDeleon/bd51bc69728f5d725a014d496d063574 to your computer and use it in GitHub Desktop.
Code to the video - "Map: Part 2 of Functional Programming in JavaScript"
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: 'Fluffykins', species: 'rabbit' }, | |
{ name: 'Caro', species: 'dog' }, | |
{ name: 'Hamilton', species: 'dog' }, | |
{ name: 'Harold', species: 'fish' }, | |
{ name: 'Ursula', species: 'cat' }, | |
{ name: 'Jimmy', species: 'fish' } | |
] |
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 names = [] | |
for (var i = 0; i < animals.length; i++) { | |
names.push(animals[i].name) | |
} |
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 names = animals.map(function(animal) { return animal.name }) |
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 names = animals.map(function(animal) { animal.name + ' the ' + animal.species }) |
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 names = animals.map((animal) => animal.name) |
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 names = animals.map((x) => x.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment