compose function in the code below takes any number of functions, returns a function that takes the initial value, and then uses the
reduceRight function to iterate right-to-left over each function
functions argument and returns the accumulated value
y. In other words, the
compose function creates a pipeline of functions with the output of the function is connected to the input of the next function.
1const compose = (...functions) => (x) =>2 functions.reduceRight((y, f) => f(y), x)34const g = (n) => n + 15const f = (n) => n * 26const h = compose(f, g)7h(20) // => 42