Quick actions

cmd+k|ctrl+k

Navigation

Languages

Reduce example

Snippet info

Language

JavaScript

Visibility

public

Author

nvmarcosalex

Created

2018-10-04T14:35:44Z

Updated

2018-10-04T19:20:01Z

const iceCreamStats = [
    {name: 'Amanda', gallonEaten: 1.0},
    {name: 'Marcos', gallonEaten: 2.0},
    {name: 'Julia', gallonEaten: 4.0},
    {name: 'Bruno', gallonEaten: 3.0}
]

const total = iceCreamStats.reduce((accumulator, currentValue) => {
    return accumulator + currentValue.gallonEaten
}, 0);

console.log(total);
INFO