Skip to content

Instantly share code, notes, and snippets.

@ancyrweb
Created January 12, 2022 02:35
Show Gist options
  • Save ancyrweb/0182a7af1c18e442b7df336ebd156e97 to your computer and use it in GitHub Desktop.
Save ancyrweb/0182a7af1c18e442b7df336ebd156e97 to your computer and use it in GitHub Desktop.
const users = [
{
name: "Jane",
balance: 100,
},
{
name: "John",
balance: 75,
},
{
name: "Ellis",
balance: 31.3,
},
];
const addBalance = (balance, user) => balance + user.balance;
const balanceSum = users.reduce(addBalance, 0); // 206.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment