Skip to content

Instantly share code, notes, and snippets.

@Chalarangelo
Created September 14, 2017 08:30
Show Gist options
  • Save Chalarangelo/1ca9a233ee953353b02389b2a8d1a81f to your computer and use it in GitHub Desktop.
Save Chalarangelo/1ca9a233ee953353b02389b2a8d1a81f to your computer and use it in GitHub Desktop.
// 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