Skip to content

Instantly share code, notes, and snippets.

@ericelliott
Created January 4, 2017 00:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ericelliott/9ae83562843b9b9f3b2f13ffb3fe54a4 to your computer and use it in GitHub Desktop.
Save ericelliott/9ae83562843b9b9f3b2f13ffb3fe54a4 to your computer and use it in GitHub Desktop.
Map with custom data type
const double = n => n.points * 2;
const doubleMap = numbers => numbers.map(double);
console.log(doubleMap([
{ name: 'ball', points: 2 },
{ name: 'coin', points: 3 },
{ name: 'candy', points: 4}
])); // [ 4, 6, 8 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment