Created
September 14, 2017 08:30
-
-
Save Chalarangelo/1ca9a233ee953353b02389b2a8d1a81f to your computer and use it in GitHub Desktop.
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
// An array of objects. | |
var myFriends = [ | |
{ name: "John", surname: "Smith", age: 52}, | |
{ name: "Sarah", surname: "Smith", age: 49}, | |
{ name: "Michael", surname: "Jones", age: 46}, | |
{ name: "Garry", surname: "Thomas", age: 48} | |
]; | |
// A simple function to get just the name and | |
// surname in one string. | |
var fullName = function(x){ | |
return x.name + " " + x.surname; | |
} | |
myFriends.map(fullName); | |
// Should output | |
// ["John Smith", "Sarah Smith", "Michael Jones", "Garry Thomas"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment