Sikau

JavaScript · Day 34 · about 30 min

Asking questions of a list

find, includes, some, every, reduce.

Questions, answered

"Is there any milk?" "Did everyone pay?" "What's the total?" Arrays can answer questions like these in one line each.

find, some, every

const ages = [14, 22, 9, 31];

console.log(ages.find((a) => a >= 18));
console.log(ages.some((a) => a < 10));
console.log(ages.every((a) => a > 5));

The rest of this lesson

  • reduce: boil it downexplain
  • Tracing reduceexplain
  • Predict the outputpredict
  • Which method answers it?match
  • Your turnwrite code
  • Challengechallenge
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 68 lessons of JavaScript