findIndex: Return the position of the first element which satisfies the condition

PHOTO EMBED

Fri Sep 16 2022 16:38:57 GMT+0000 (Coordinated Universal Time)

Saved by @sreejithbs

const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook']
const ages = [24, 22, 25, 32, 35, 18]

const result = names.findIndex((name) => name.length > 7)
console.log(result) // 0

const age = ages.findIndex((age) => age < 20)
console.log(age) // 5
content_copyCOPY

https://github.com/Asabeneh/30-Days-Of-JavaScript/blob/master/09_Day_Higher_order_functions/09_day_higher_order_functions.md