BeginnerCoder

Lesson 12 — find / some / every

Asking questions about an array

Three methods answer common questions:

  • find(test) — the first item that passes, or undefined;
  • some(test) — true if at least one item passes;
  • every(test) — true only if all items pass.
[15, 22].find((age) => age > 18);    // 22
[15, 22].every((age) => age > 18);   // false

Why it matters: "is anyone an admin?", "are all fields filled?" — these one-liners replace whole loops.

Want it another way?
Task

Use find to get the first adult, some to check for any admin, and every to check all are adults.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.