Skip to content
dreamcode
dreamcode
Map
Array reduce
Lesson 27 of 48
+15 XP on finish
JAVASCRIPT CLIMBSChapter 5 · JS Functions and Classes

The Reduce Method

The .reduce() method executes a reducer function on each element, resulting in a single output value.

Worked example

How it reads

  • accumulator accumulates the callbacks' return values
  • 0 is the initial value of the accumulator parameter
Cloud tip: The initial value is optional but highly recommended to avoid errors on empty arrays.
index.js
JAVASCRIPT
real JavaScript, runs in your browser
Console
Run your code to see its output here.
YOUR TURN

Use reduce to find the most expensive price and log it: 30.

Press Run to check your work.