
const numbers = numbers.indexOf(2) //=> 1 numbers.indexOf(9) //=> -1. Takes an item (and optional start) and returns the Index or -1. const numbers = const isEven = number => number % 2 = 0 const isLessThanZero = number => number 1 numbers.findIndex(isLessThanZero) //=> -1. Takes a predicate and returns the Index or -1. const numbers = const isEven = number => number % 2 = 0 const isLessThanZero = number => number 2 numbers.find(isLessThanZero) //=> undefined Find The Index of Matching Item. Takes a predicate and returns the first matching item or undefined. everyĪlso searches for multiple items, see implementation below. const numbers = const isEven = number => number % 2 = 0 const isLessThanZero = number => number numbers.filter(isLessThanZero) //=>.

Takes a predicate and returns an Array of all matching items.

const isEven = number => number % 2 = 0 Searching for Multiple Items. The isEven function is an example of a predicate that takes a number and returns true if the number is even. A predicate is just a fancy word for a function that takes an item and returns a Boolean whether the item passes some condition.
