Skip to solution
mediumDSA

Implement curry(func) with placeholder support

663 views
01

Understand the problem

Create curry that transforms f(a,b,c) into f(a)(b)(c) or f(a,b)(c). Support lodash-style placeholder _. Use func.length for arity.

curryclosurepartial-application
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

Approach: Accumulate args until arity met; placeholder version needs gap filling. Simple version covers 90% of interviews; placeholder extended is bonus.

function simpleCurry(fn, arity = fn.length) {
  return function curried(...args) {
    if (args.length >= arity) return fn.apply(this, args);
    r

Solution ready — 2 min read

Classified // press E to declassify

04

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 132 of 190 decoded in the JavaScript Coding track. One more won't hurt.

Back to track