I'm trying to make a function work with this two calls:
func(1)(2); // 3
func(1, 2); // 3;
What i'm trying to do:
function func(x, y) {
return (function(y) {
return x + y;
}(y));
}
But this won't work at all when i try to call in sequence. Is there other way to achieve that?
function add(x, y) {
if (y) return x + y;
return function(y) {
return x + y;
};
}
This would work, but i think it could be a better solution.
Thanks.