Iterates over an array of values and only outputs values where predicate is equal to true
.
array
(Array): input arraypredicate
(Function): predicate function
(Array): the input array w/ unwanted values removed
const result = arrays.filter([1, 2, 3, 4], (x) => x % 2 === 0);
console.log(result)
> [ 2, 4 ]