en.javascript.info/1-js/06-advanced-functions/06-function-object/5-sum-many-brackets/task.md
Ilya Kantor 97c8f22bbb up
2017-03-21 17:14:05 +03:00

341 B

importance: 2


Sum with an arbitrary amount of brackets

Write function sum that would work like this:

sum(1)(2) == 3; // 1 + 2
sum(1)(2)(3) == 6; // 1 + 2 + 3
sum(5)(-1)(2) == 6
sum(6)(-1)(-2)(-3) == 0
sum(0)(1)(2)(3)(4)(5) == 15

P.S. Hint: you may need to setup custom object to primitive conversion for your function.