-
-
Save atticoos/2c8a8f3fe1433bd5c58a556ea869c22e to your computer and use it in GitHub Desktop.
Map with custom data type
This file contains hidden or 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 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