const compose = (...fns) => x => fns.reduceRight((acc, fn) => fn(acc), x);
const pipe = (...fns) => x => fns.reduce((acc, fn) => fn(acc), x);
const add = n => x => x + n;
const mul = n => x => x * n;
const composed = compose(add(3), mul(2));
const piped = pipe(add(3), mul(2));
console.log(composed(5), piped(5));
Post #3464
2.17K
CHALLENGE
- 🔥 4
- ❤ 1