sum(a)(b)(c).....(n)

Difficulty: medium

Implement sum(a)(b)(c)...(), a curried sum that can accept any number of chained numeric calls.

The empty call () is the signal that the chain is finished and the accumulated total should be returned.

More JS Coding

View all JS Coding →
JS CodingMedium

5. Throttle

JS CodingMedium

13. Deep Clone

JS CodingMedium

14. Event Emitter

JS CodingEasy

66. Promise Methods

JS CodingEasy

19. Memoize I

JS CodingMedium

86. API Retry

Related hubs

  • All JavaScript coding
  • JavaScript interview questions
  • JS polyfill interview questions
  • Debounce & throttle questions
  • React interview hub

FAQ

What is currying, and why is it asked?

Currying turns a multi-argument function into a chain of single-argument calls. It tests closures, partial application, and creative API design.

What follow-ups are common?

sum(1)(2)(3), infinite currying with valueOf/toString, and converting between curry and partial apply.

Related practice?

currying-mul, memoize, and debounce/throttle.