Skip to solution
hardFrontend

What is currying?

563 views
01

Understand the problem

Question presented to candidate: "What is currying, and can you show me how you'd write a generic curry() helper that works for any function, regardless of how many arguments it takes?"

What a strong answer should cover:

  • 📌 Interview term: currying — transforming a function that takes multiple arguments into a sequence of functions, each taking a single argument (or a subset), where calling with fewer than all the needed arguments returns a new function waiting for the rest.
  • 📌 Interview term: the real, direct answer to the prompt — verified directly: a generic curry(fn) helper genuinely worked correctly across three different calling patterns for the same 3-argument function — all-at-once (curriedAdd3(1, 2, 3)), one-then-two (curriedAdd3(1)(2, 3)), and fully split (curriedAdd3(1)(2)(3)) — all producing the identical, correct real result.
  • 📌 Interview term: partial application — currying's most common real, practical payoff: calling a curried function with FEWER than all its arguments produces a new, reusable, "pre-configured" function — verified directly with a real tax-calculation example, where partially applying just the tax rate produced a genuinely reusable function correctly applied to multiple different prices.
  • A precise answer names fn.length as the real mechanism most generic curry implementations use to know how many arguments to wait for before actually invoking the original function — a precise, verified detail beyond just describing the general idea.
  • A precise answer distinguishes currying from simple partial application via bind: bind pre-fills a fixed number of leading arguments once; a curried function genuinely supports being called with any split of arguments across any number of calls, not just one fixed split.

Clarifying questions expected:

  • None — this is a definitional/technical question; producing a real, working generic curry implementation (not just a hard-coded 2-argument example) is the strong signal.

Code / implementation expected: Yes — a real, generic curry() helper verified to work across multiple calling patterns for the same function is the clearest, most convincing demonstration.

currying
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Nudge consolestandby

Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.

03

Study the solution

Target Audience: Engineers preparing for JavaScript fundamentals/functional-programming interviews. Difficulty: Medium

How to read this doc: Concepts are explained in plain language first, then tagged with 📌 Interview term:. The generic curry helper and its three calling patterns below were

Solution ready — 2 min read

Classified // press E to declassify

04

Run the code

JSA real, generic curry() helper verified across multiple argument-splitting patterns, plus a real partial-application example
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.

Transmission complete // awaiting log

KEEP THE
STREAK ALIVE.

Dossier 144 of 165 decoded in the JavaScript track. One more won't hurt.

Back to track