Question
Write a function called compose
that accepts multiple functions as arguments and returns a new function. The new function should apply the input functions in reverse order, passing the result of each function call as an argument to the next.
function double(x) {
return x * 2;
}
function square(x) {
return x * x;
}
function increment(x) {
return x + 1;
}
const composedFunction = compose(increment, square, double);
const result = composedFunction(10); // Result: 401
🤫 Check the comment below to see answer.
Top comments (1)