Knowledgize

.findIndex()

Returns the index of the first element in the array that satisfies the provided testing function.

Examples:

let numbers = [5, 12, 8, 130, 44]; let largeNumIndex = numbers.findIndex(num => num > 100); console.log(largeNumIndex); // 3
let people = [{ name: 'Jack', age: 20 }, { name: 'Laura', age: 18 }]; let adultIndex = people.findIndex(person => person.age >= 18); console.log(adultIndex); // 0