const test = sum(1)(2)(3)(5); console.log(test); function sum(a) { let temp = function(b) { return sum(a + b); } temp.toString = function() { return a; } return temp; }