← All Exercises

Curry Function

intermediatejavascript~25min

Background

Currying is a fundamental concept in functional programming, enabling partial application and function composition.

Problem

Write a curry function that takes a multi-argument function and returns a curried version that accepts arguments one at a time until all are provided.

Input

A function with one or more parameters.

Output

A curried function that can be called with partial arguments.

Sample tests

Sample 1

Input: curry(add)(1)(2)
Expected: 3

Your solution

Learning objective

Understand currying, partial application, and recursive function construction with closures.