The findIndex()
function will return the index number of the first item in a list that matches the condition. If you want to return the item itself, use find.
Code language: JavaScript (javascript)
Note that lists use zero-based indexing, so 0
will be returned for the first value.
Example Formulas
This formula finds the index of the first item in the list that can be parsed to a date:
Code language: JavaScript (javascript)
This variation finds the index of the first item that can be parsed to a date and that is before Jan 1, 2000:
Code language: JavaScript (javascript)