Created
April 4, 2019 14:00
-
-
Save vitorpiovezam/b764f59125ae0ef70ad1cf9b11d7e3b7 to your computer and use it in GitHub Desktop.
es6 map
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
const students = [ | |
{ name: 'Anna', grade: 6 }, | |
{ name: 'John', grade: 4 }, | |
{ name: 'Maria', grade: 9 } | |
]; | |
const teachers = [ | |
{ name: 'Mark', salary: 2500 }, | |
{ name: 'Todd', salary: 3700 }, | |
{ name: 'Angela', salary: 1900 } | |
]; | |
const byName = object => object.name; | |
const byNames = list => list.map(byName); | |
byNames(students); // ["Anna", "John", "Maria"] | |
byNames(teachers); // ["Mark", "Todd", "Angela"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment