Implement a function compose(...fns) that takes multiple functions as arguments and returns a new function that applies those functions in reverse order (from right to left).
Examples
const add = x => x + 1; const double = x => x * 2; const fn = compose(add, double); fn(2); // double(2) = 4, add(4) = 5 const fn2 = compose(Math.sqrt, x => x + 1, x => x * 2); fn2(3); // ((3 * 2) + 1) = 7, sqrt(7) ≈ 2.6457513110645907
JavaScript Function
No test results yet
Click "Run" to execute tests