The find()
function will return the first item in a list that matches the condition. If you want to return the index of the item instead, use findIndex.
find(list, condition)
list.find(condition)
Code language: JavaScript (javascript)
Example Formulas
This formula finds the first item in the list that can be parsed to a date:
[1, "Monkey D. Luffy", true, "2025-01-01", 37, "1999-12-23"].find(
current.parseDate()
)
/* Output: "2025-01-01" */
Code language: JavaScript (javascript)
This variation finds the first item that can be parsed to a date and that is before Jan 1, 2000:
[1, "Monkey D. Luffy", true, "2025-01-01", 37, "1999-12-23"].find(
current.parseDate() < "2000-01-01".parseDate()
)
/* Output: "1999-12-23" */
Code language: JavaScript (javascript)