← JavaScript

Arrays – reduce()

Combines every element of an array into a single value using an accumulator function.

Understanding Arrays – reduce() in JavaScript

What it does: This is exactly what the reduce() method does. The second argument to reduce() is the starting accumulator value. reduce() returns a single value, not an array. Without return, the accumulator wouldn't carry forward correctly. JavaScript is case-sensitive, so the method must start lowercase. reduce() leaves the original array untouched. reduce() can add each number to a running total. The accumulator multiplies with each number in turn.

Common mistakes: 'reduce' must start lowercase - a capital R causes an error. Missing the 'return' keyword - without it, nothing is carried forward.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 21–30) and word search (Modules 1–29) and word search (Modules 21–52).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Does reduce() combine all elements into a single value?
YesNo
Matches
nums.Reduce(function(t, n) { return t+n; }, 0)
↓
Wrong - 'reduce' must start with a lowercase r
Applying
Meanings
Term
reduce()
Meaning
Combines every element of an array into a single value using an accumulator function.
Practice
let nums = [1, 2, 3, 4];
Testing
Gaps
let sum = nums.(function(total, n) {
Check Answer
Spots
1let a = [1, 2, 3];
2let b = a.Reduce(function(t, n) {

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Kangaroo Rat' badge — Speed Typer, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Does reduce() combine all elements into a single value?
A. Yes ✓
B. No
reduce() carries an accumulator forward to produce one final value.
2. Does reduce() return a new array like map() does?
A. No ✓
B. Yes
reduce() returns a single value, not an array.
3. Is a return statement needed inside reduce()'s function?
A. No
B. Yes ✓
Without return, the accumulator wouldn't carry forward correctly.
4. Can reduce() take a starting value as a second argument?
A. No
B. Yes ✓
The starting value, like 0, sets the initial accumulator.
5. Is 'Reduce' with a capital R valid JavaScript syntax?
A. No ✓
B. Yes
JavaScript is case-sensitive, so the method must start lowercase.

Match the Pairs

nums.reduce(function(total, n) { return total + n; }, 0) → Adds up every number in nums into a single total
nums.reduce(function(total, n) { return total * n; }, 1) → Multiplies every number in nums into a single product
Combines every element into a single result value → array.reduce(function(total, item) { ... })
Sets the accumulator's value before the loop begins → 0
nums.Reduce(function(t, n) { return t+n; }, 0) → Wrong - 'reduce' must start with a lowercase r
nums.reduce(function(t, n) { t + n; }, 0) → Wrong - missing the 'return' keyword

Key Term

reduce()
Combines every element of an array into a single value using an accumulator function.

Fill in the Blanks

1. let sum = nums.reduce(function(total, n) {
Hint: Type the array method that combines all elements into one value.
2. let sum = nums.reduce(function(total, n) {
Hint: Type the keyword used to define the function passed to reduce.
3. return total + n;
Hint: Type the keyword that sends the running total back.
4. let product = nums.reduce (function(total, n) {
Hint: Type the array method that combines all elements into one value.
5. let product = nums.reduce(function(total, n) { return total * n; }, 1);
Hint: Type the keyword that sends the running total back.

Spot the Error

Question 1
A let a = [1, 2, 3];
B let b = a.Reduce(function(t, n) {
C return t + n;
Line B — 'reduce' must start lowercase - a capital R causes an error.
Question 2
A let c = [1, 2, 3];
B let d = c.reduce(function(t, n) {
C t + n;
Line C — Missing the 'return' keyword - without it, nothing is carried forward.
Question 3
A let e = [1, 2, 3];
B let f = e.map(function(t, n) {
C return t + n;
Line B — map() doesn't combine values into one - use reduce() instead.
Question 4
A let g = [1, 2, 3];
B let h = g.reduce(function(t, n) {
C return t + n
D }, 0);
Line C — This line is missing a semicolon, but that's not required in JS.
Question 5
A let i = [1, 2, 3];
B let j = i.reduce(function(t, n) {
C return t + n;
D ], 0);
Line D — The block must close with }, not ].

Student with a class code? Join your class →