Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const reduce = (fn, initValue, list) => {
- if (list.length === 0) {
- return initValue
- }
- const [fst, ...rest] = list
- return reduce(fn, fn(initValue, fst), rest)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement