Closures & Functions

Implement Compose

easyJS SpecificJS / TS3 tests

Problem Statement

Implement `compose(...fns)`, which performs right-to-left function composition. The rightmost function can accept any number of arguments, and its result is piped to the preceding functions.

Examples

Example 1:
const square = (x) => x * x;
const double = (x) => x * 2;
const add = (a, b) => a + b;
const compute = compose(square, double, add);
compute(1, 2); // ((1 + 2) * 2)^2 = 36
JavaScript & TypeScript starter code included
Run this as a live interview

Practice solo

3 test cases. No second person needed.

Get new interview exercises

Practice problems and review drills, sent when we publish new ones. No spam.

Unsubscribe anytime. We never share your address.