js add(1,2) = 3 add(1,2)(3) =6

function add(…arg) {
let mem = […arg];
let fn = function(…arg) {
return add(…[…mem, …arg]);
}
fn.valueOf = fn.toString = function() {
return mem.reduce(function(a, b) {
return a + b;
});
}
return fn;
}

    let sum = add(1,2,3)(4,5)(6);

    console.log((sum+1));
console.log(add(1, 2)(3));