Function Composition

Easy

Solution

type F = (x: number) => number;
 
export function compose(functions: F[]): F {
  return (x) => functions.reduceRight((acc, func) => func(acc), x);
}