Skip to content

Instantly share code, notes, and snippets.

@mozkoq
Created March 20, 2017 17:39
filter js (reduce)
const filter = (pred, arr) => {
const DEFAULTSTATE = []
return arr.reduce(
(result, current, i, reducingArray) =>
pred(current, i, reducingArray)
? [...result, current]
: result,
DEFAULTSTATE
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment