Javascript function challenge add(1,2) and add(1)(2) both should return 3
I wrote a curried function whose valueOf() method and function context (this) are bound with the sum no matter how many arguments are passed each time. /* add function */ let add = function add(…args) { const sum = args.reduce((acc, val) => acc + val, this); const chain = add.bind(sum); chain.valueOf = () => sum; … Read more