Facebook Pixel

What follow-up should I expect after solving sum(1)(2)(3)?

How would you support multiple arguments (sum(1, 2)(3)), how would you add other operations (multiply), how would you make it a generic curry, and what is the time/space complexity.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in sum(1)(2)(3) Interview Tips for Amazon

Recognize it as currying. Start with the simple solution (terminate with empty call). Explain how closures accumulate the sum. Mention toString as an alternative. Handle follow-ups like multiple arguments.

Not returning a function (the chain breaks), not accumulating the previous value, no termination mechanism (no way to get the result), and overcomplicating (using classes or complex state instead of a simple closure).

Yes. After the basic solution, mention that you could also use toString or valueOf for automatic type coercion. This shows deeper JavaScript knowledge (type coercion, toString, valueOf).

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.