The Master Accumulator

Hard+35 XP

Mission Briefing

The Grand Treasurer's ledger is completely full of isolated transactions! You need to calculate the supreme total of all wealth in the treasury using the ultimate aggregator.

The Concept: Boiling Down Data

The .reduce() method is the powerhouse of arrays. It executes a "reducer" function that accumulates all elements into a single output value. Example:

const total = [1, 2, 3].reduce((acc, curr) => acc + curr, 0); // 6

The Objective

Your function receives an array prices.

  1. Use .reduce() to calculate the sum of all prices.
  2. Return that total number.

01EXAMPLE 1

Inputprices = [10, 20, 30]
Output60

Constraints

  • Use the .reduce() method.
CoreArraysMethods
JavaScript
Loading...
3 Hidden

Input Arguments

prices[10,20,30]

Expected Output

60

Click RUN to test your solution