Prompt
Implement a function sum that adds numbers by chaining function calls. Unlike mul(a)(b)(c) which has a fixed number of calls, sum should support any number of chained calls. Calling with empty parentheses () at the end signals that you're done and want the final result.
sum(1)(); // Returns 1sum(1)(2)(3)(); // Returns 6sum(5)(-1)(2)(4)(); // Returns 10