Return the index of the first element of an array where the callback returns true. Returns -1 if none do.
npm install @bemoje/arr-index-of-first-where
npm install --save @bemoje/arr-index-of-first-where
npm install --save-dev @bemoje/arr-index-of-first-where
import arrIndexOfFirstWhere from '@bemoje/arr-index-of-first-where'
const arr = [1, 2, 3, 4, 5]
arrIndexOfFirstWhere(arr, (element) => {
return element >= 3
})
//=> 2
arrIndexOfFirstWhere(arr, (element) => {
return element >= 6
})
//=> -1
Uses Jest to test module functionality. Run tests to get coverage details.
npm run test
Return the index of the first element of an array where the callback returns true. Returns -1 if none do.
any The first element to satisfy the condition
Type: Function