frontend-challenges icon indicating copy to clipboard operation
frontend-challenges copied to clipboard

471 - Pipe - javascript

Open jsartisan opened this issue 2 months ago • 0 comments

index.js

/**
 * Creates a function that pipes values through a sequence of functions.
 * @param {Function[]} functions - array of unary functions
 * @returns {Function} composed function
 */
export function pipe(functions) {
  // TODO: Implement me
  return (initialArg) => {
    return functions.reduce((acc, current) => {
      acc = current(acc);

      return acc;
    }, initialArg)
  };
}

jsartisan avatar Sep 27 '25 04:09 jsartisan