0

Sum(6)(2,3)(6,7,8)() = 32

Sum() = 0

Sum(6,1,3)() = 10

Needs to evaluate this with single function.

anandharshan
  • 5,817
  • 4
  • 34
  • 33
  • I would just add up all the numbers. that's what sum means. – Rick Feb 21 '21 at 18:11
  • See [this answer](https://stackoverflow.com/a/66305648/5459839) in the duplicate reference. – trincot Feb 21 '21 at 18:28
  • function add(...args) { if (args.length === 0) return 0; let sum = args.reduce((a, b) => a+b, 0); return (...args) => args.length ? add(sum, ...args) : sum; } – anandharshan Feb 21 '21 at 18:32

0 Answers0