Typorithm · easy

find, some, every, includes

array-searchcollectionsfindsomeevery
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn find, some, every, includes

0%

Array Methods

find returns the first element matching a predicate (or undefined); some and every return booleans for any-match and all-match; includes is a value check returning a boolean, and indexOf returns the value's position or -1. Predicate searches take a callback; value searches take a literal value.

Predicate searches take a callback. find returns the first matching element (or undefined); some returns true if any element matches; every returns true only if all elements match.

Value searches take a literal value instead of a callback. includes returns a boolean for whether the value is present; indexOf returns its position, or -1 if it is missing.

Choose by what you need back: an element (find), a yes/no (some, every, includes), or a position (indexOf).

01

find returns an element or undefined.

02

some and every return booleans (any vs all).

03

includes returns a boolean; indexOf returns an index or -1.

const nums = [3, 7, 12, 5, -2];
const firstBig = nums.find((n) => n > 10);
const hasNeg = nums.some((n) => n < 0);
const allPos = nums.every((n) => n > 0);
const has5 = nums.includes(5);
const where5 = nums.indexOf(5);

Read the implementation

Connect each part of the code to the concept before you type.

1. find returns an element

find runs a predicate and returns the first matching element, or undefined if none match.

const firstBig = nums.find((n) => n > 10);

2. some returns a boolean

some returns true as soon as any element passes the predicate.

const hasNeg = nums.some((n) => n < 0);

3. every returns a boolean

every returns true only when every element passes the predicate.

const allPos = nums.every((n) => n > 0);

4. includes returns a boolean

includes does a value check and returns true when the array contains that exact value.

const has5 = nums.includes(5);

5. indexOf returns an index

indexOf returns the position of the value, or -1 when it is absent.

const where5 = nums.indexOf(5);

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

find, some, every, includes: Lesson & Practice · Typorithm | ApplyDjinn