JavaScript 2025 · Arrays

Combine items into one value

Add up a property across an array. The second argument is the starting value.

const total = items.reduce((sum, item) => sum + item.price, 0);

Official JavaScript 2025 documentation

More arrays commands

All arrays commands · JavaScript 2025 cheatsheet

Was this page helpful?