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.
- Use
.reduce()to calculate the sum of all prices. - Return that total number.
01EXAMPLE 1
Input
prices = [10, 20, 30]Output
60Constraints
- Use the .reduce() method.
CoreArraysMethods
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
prices[10,20,30]
Expected Output
60
Click RUN to test your solution