FrontendInterviews.dev

Loading problem…

154. Pipe Function

Easy•

Implement a pipe utility for left-to-right function execution.

Requirements

Implement:

function pipe(functions) {}

Behavior:

  • pipe([f, g, h])(x) should run as h(g(f(x)))
  • Functions are synchronous in this variant
  • If functions is empty, return identity function
  • If one function is provided, return equivalent single-step transform

Constraints

  • Must execute left-to-right
  • Must return a function
  • Must support empty array as identity
  • Must support any unary function list
Accepted20/24|Acceptance Rate83.3%