Last active
January 12, 2022 06:56
-
-
Save ancyrweb/56a3b13f426e27c3ac1f1959e3d8532e to your computer and use it in GitHub Desktop.
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 users = [ | |
{ | |
name: "Jane", | |
balance: 100.00 | |
}, | |
{ | |
name: "John", | |
balance: 55.25 | |
} | |
]; | |
// define pure methods for our `map` | |
const double = (amount) => amount * 2; | |
const doubleUserBalance = (user) => ({ | |
...user, | |
balance: double(user.balance), | |
}); | |
// transform all the users | |
const usersWithDoubledBalance = users.map(doubleUserBalance); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment