Open this example in the interactive library
Source code
const compose = (f, g) => (x) => f(g(x));
console.log(
compose(
(x) => x * 2,
(x) => x + 3,
)(4),
);
Sample output
14

Compose two functions. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
const compose = (f, g) => (x) => f(g(x));
console.log(
compose(
(x) => x * 2,
(x) => x + 3,
)(4),
);
14