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