All Challengesbeginner
Array basics: find vs filter
Two array methods that look similar but behave very differently.
arraysfindfilterbasics
javascript
const users = [
{ id: 1, name: 'Alice', active: true },
{ id: 2, name: 'Bob', active: false },
{ id: 3, name: 'Carol', active: true }
]
const result1 = users.find(u => u.active)
const result2 = users.filter(u => u.active)Question
What is the difference between result1 and result2?