findBack
Finds the last element in an array that satisfies a predicate function.
Throws
Error: If thearrayisempty.Error: If no element in thearraysatisfies thepredicatefunction.
Type
type findBack = <E>(predicate: ((e: E) => boolean)) => (a: Array<E>) => E
Example
import {findBack} from 'fnxt/array';
function isEven(num: number): boolean {
return num % 2 === 0;
}
const array = [1, 2, 3, 4, 5];
const lastEven = findBack(isEven)(array);
// lastEven is 4