Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 584 Bytes

filter.md

File metadata and controls

33 lines (21 loc) · 584 Bytes

arrays.filter

filter(array, predicate)

Iterates over an array of values and only outputs values where predicate is equal to true.

Arguments

  1. array (Array): input array
  2. predicate (Function): predicate function

Returns

(Array): the input array w/ unwanted values removed

Example

const result = arrays.filter([1, 2, 3, 4], (x) => x % 2 === 0);
console.log(result)
> [ 2, 4 ]