Skip to content

Instantly share code, notes, and snippets.

@ancyrweb
Last active January 12, 2022 06:56
Show Gist options
  • Save ancyrweb/56a3b13f426e27c3ac1f1959e3d8532e to your computer and use it in GitHub Desktop.
Save ancyrweb/56a3b13f426e27c3ac1f1959e3d8532e to your computer and use it in GitHub Desktop.
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