JavaScript · Arrays
reduce
Folds an array into a single value. Always pass an initial value when the type matters.
Syntax
items.reduce((acc, item) => acc + item, 0)Example
Try it
More in this group
Learn this in the course
Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.