Skip to content

Instantly share code, notes, and snippets.

@atticoos
Forked from ericelliott/map-custom-data-type.js
Last active January 7, 2017 01:03
Show Gist options
  • Save atticoos/2c8a8f3fe1433bd5c58a556ea869c22e to your computer and use it in GitHub Desktop.
Save atticoos/2c8a8f3fe1433bd5c58a556ea869c22e to your computer and use it in GitHub Desktop.
Map with custom data type
const double = n => n * 2;
const doublePoints = obj => double(obj.points);
const doubleMap = numbers => numbers.map(doublePoints);
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