We can use findLastIndex
function from lodash to find the index of the last element in an array for which a given predicate function returns true.
Here's an example of how to use findLastIndex
function:
index.tsx306 chars12 lines
In the above example, we are finding the index of the last user object in the array users
for which the age is greater than 30. The findLastIndex
function returns the index of the matched element, which is 1 in this case.
gistlibby LogSnag