testFunction: (value, index, array) => boolean,
array
): number[]
getIndexesThatPass(Returns indexes of items that pass the testFunction
.
Examples
let arr = ['a', 'boy', 'is', 'playing', 'in', 'the', 'street'];
getIndexesThatPass((value) => value.length > 3, arr);
// --> [3, 6]
getIndexesThatPass((value, i) => (value.length > 3) && (i > 3), arr);
// --> [6]
Installation
npm i @writetome51/array-get-indexes-that-pass
Loading
import {getIndexesThatPass} from '@writetome51/array-get-indexes-that-pass'