Create compose(...fns) (right-to-left) and pipe(...fns) (left-to-right) that compose functions. Handle async functions.
Skip to solutionKEEP THE
mediumFrontend
Implement compose() and pipe() for function composition
1k views
01
Understand the problem
composepipefunctional
02
Attempt it yourself
Sketch your approach before reading the solution — that's what interviews test.
Nudge consolestandby
Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.
03
Study the solution
Approach: compose reduces right-to-left: (...args) => f(g(h(...args))). pipe is reverse. Provide async variants that await.
function compose(...fns) {
if (fns.length === 0) return x => x;
return function(...args) {
let result = fns[fns.length - 1].apply(this, args);
for (let i = fns
Solution ready — 2 min read
Classified // press E to declassify
04
Join the discussion
Discussion (0)
Sign in to join the discussion.
No responses yet. Be the first to share what you think.
Transmission complete // awaiting log
KEEP THE
STREAK ALIVE.
Dossier 117 of 190 decoded in the JavaScript Coding track. One more won't hurt.