Skip to content

Instantly share code, notes, and snippets.

@timgarciaa
Created July 2, 2022 13:56
Show Gist options
  • Save timgarciaa/2b7dab618c7580429b1f9fbf847b0f80 to your computer and use it in GitHub Desktop.
Save timgarciaa/2b7dab618c7580429b1f9fbf847b0f80 to your computer and use it in GitHub Desktop.
Add total price of drinks
const drinks = [
{name: 'coffee', price: 1.99},
{name: 'tea', price: 1.75},
{name: 'milk', price: 1.5},
];
const totalPrice = drinks.reduce((total, next) => total + next.price, 0);
console.log(totalPrice);
//5.24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment