Back to Problem Library
Functional Programming

Implement Currying

mediumJS / TS

Problem Statement

Write a function `curry(fn)` that transforms a function `fn` that accepts multiple arguments into a function that can be called repeatedly with single or multiple arguments until all expected arguments are provided.

Examples

Example:
const sum = (a, b, c) => a + b + c;
const curriedSum = curry(sum);
curriedSum(1)(2)(3); // 6
curriedSum(1, 2)(3); // 6
Includes TypeScript & JavaScript starter code
Start Interview with this Problem