JavaScript Academy · Lesson

reduce, some/every, find — simple patterns

Learn reduce for totals, some/every for boolean checks, and find to get the first matching item.

Lesson 2 of 28 steps

reduce, some/every, find — simple patterns is a free JavaScript Academy lesson on CoddyKit. This is lesson 2 of 2. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the JavaScript Academy learning path, and your progress syncs across the web and the CoddyKit app. The JavaScript Academy course includes 2 lessons in total.

Intro to reduce & friends

Goal: Turn many values into one with reduce, check arrays with some/every, and get the first match with find.

  • reduce: totals
  • some/every: quick checks
  • find: first match
reduce, some/every, find — simple patterns — illustration 1

reduce sum

reduce takes a callback and an initial value. Return the next accumulator each step.

// reduce: sum numbers with an initial value
const prices = [4, 6, 3];

const total = prices.reduce(function (acc, n) {
  // Add current number to the accumulator
  return acc + n;
}, 0);

console.log("Total:", total);
reduce, some/every, find — simple patterns — illustration 2

reduce min

You can compute min or max by comparing the accumulator to each value.

// reduce: smallest number
const nums = [7, 2, 9, 4];

const min = nums.reduce(function (acc, n) {
  // Keep the smaller of acc or n
  return n < acc ? n : acc;
}, Infinity);

console.log("Min:", min);
reduce, some/every, find — simple patterns — illustration 3

some basics

some returns true if any item passes the test.

// some: is there any even number?
const list = [1, 5, 8, 11];

const hasEven = list.some(function (n) {
  return n % 2 === 0;
});

console.log("Has even?", hasEven);
reduce, some/every, find — simple patterns — illustration 4

every basics

every returns true only if all items pass the test.

// every: are all ages 18+ ?
const ages = [22, 19, 31];

const allAdults = ages.every(function (a) {
  return a >= 18;
});

console.log("All adults?", allAdults);
reduce, some/every, find — simple patterns — illustration 5

find basics

find returns the first item that matches your test, or undefined if none match.

// find: get the first matching value (or undefined)
const users = [
  { name: "Ayla", active: true },
  { name: "Mina", active: false },
  { name: "Lena", active: true }
];

const firstInactive = users.find(function (u) {
  return u.active === false;
});

console.log("First inactive:", firstInactive);
reduce, some/every, find — simple patterns — illustration 6

reduce concept quiz

Quick check: Accumulator method.

reduce, some/every, find — simple patterns — illustration 7

Recap

Recap: Use reduce for totals or min/max, some to check “any?”, every to check “all?”, and find to grab the first matching item.

reduce, some/every, find — simple patterns — illustration 8
Free to start

Learn JavaScript with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
59
Lessons
200

Frequently Asked Questions

Is the “reduce, some/every, find — simple patterns” lesson free?

Yes — any 3 lessons of the JavaScript Academy learning path, including “reduce, some/every, find — simple patterns”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The JavaScript Academy course includes 2 lessons in total.

What will I learn in “reduce, some/every, find — simple patterns”?

Learn reduce for totals, some/every for boolean checks, and find to get the first matching item. You practise JavaScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start JavaScript Academy?

No prior experience is required. JavaScript Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 2 of 2.

How long does the “reduce, some/every, find — simple patterns” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this JavaScript Academy lesson?

Yes. Every JavaScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. map & filter — essentials
  2. reduce, some/every, find — simple patterns
← Back to JavaScript Academy