Created
July 2, 2022 13:56
-
-
Save timgarciaa/2b7dab618c7580429b1f9fbf847b0f80 to your computer and use it in GitHub Desktop.
Add total price of drinks
This file contains 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 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