Skip to content

Instantly share code, notes, and snippets.

@buymed-hoangpham
Created September 11, 2022 09:37
Show Gist options
  • Save buymed-hoangpham/d4172cab2757509560b349d0c0e7f34e to your computer and use it in GitHub Desktop.
Save buymed-hoangpham/d4172cab2757509560b349d0c0e7f34e to your computer and use it in GitHub Desktop.
7
const trips = [
{ to: 'Brazil', distance: 1000 },
{ to: 'Chine', distance: 2500 },
{ to: 'India', distance: 3000 },
];
const totalDistanceTraveled = trips.reduce(
(sum, cur) => (sum += cur.distance),
0
);
console.log(
'🚀 ~ file: index.js ~ line 11 ~ totalDistanceTraveled ~ totalDistanceTraveled',
totalDistanceTraveled
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment