MediumArray Methods💻 Output Question

find returns first match; filter returns all

💡

Hint

find = first match (or undefined). filter = all matches (always an array).

What does this output?

const users = [
  { id: 1, name: 'Alice' },
  { id: 2, name: 'Bob' },
  { id: 3, name: 'Alice' },
];
const first = users.find(u => u.name === 'Alice');
const all   = users.filter(u => u.name === 'Alice');
console.log(first.id);
console.log(all.length);

Correct Output

1
2

Why this output?

Explanation: find returns the first Alice (id=1). filter returns all Alices — 2 results.

Key Insight: find = first match (or undefined). filter = all matches (always an array).

More Array Methods Output Questions

Easymap transforms each elementMediumfilter then map chainMediumreduce accumulates to a single valueMediumreduce to build a frequency object

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz