Example 1 — First Matching Number
Return the first value greater than 20—later matches are ignored.
const numbers = [10, 25, 5, 40, 15];
const result = numbers.find((n) => n > 20);
console.log(result); // 25 How It Works
- Scan from the left. Starts at index
0. - Skip 10.
10 > 20is false. - Hit 25. First truthy test → return
25immediately. - 40 is ignored. Even though it also matches,
findalready stopped.

