I need a js sum function to work like this:
sum(1)(2) = 3 sum(1)(2)(3) = 6 sum(1)(2)(3)(4) = 10 etc.
I heard it can\'t be done. But heard
let add = (a) => { let sum = a; funct = function(b) { sum += b; return funct; }; Object.defineProperty(funct, 'valueOf', { value: function() { return sum; } }); return funct; }; console.log(+add(1)(2)(3))