Array.prototype.findLastintermediateconst logs = [{type:'err'}, {type:'info'}, {type:'err'}]
logs.findLast(l => l.type === 'err') // β {type:'err'} (last one)Use findLast() to locate the most recent object in an array matching a property condition.
Like find(), findLast() works on any element type, including objects. It returns the last object in the array that satisfies the predicate.
Challenge: Implement findLastActive(users) that returns the last user with active: true.
findLastActive([{name:'A',active:true},{name:'B',active:false},{name:'C',active:true}])
// β {name:'C', active:true}