This is a simplified version with addition of 2 numbers:
const sum = (a) => {
return function(b) {
return a + b;
}
}
console.log(
sum(2)(2)
);
This is a more difficult option.
I couldn't find this problem on google, but I'm just wondering how to solve this. I couldn't think of a solution.
const sum = (a) => {
// How to make it?
}
console.log(
sum(2)(2)(4)() // Expected result: 8
sum(2)(2)(4)(4)(4)() // Expected result: 16
sum(2)(2)(4)(10)(20)(1)() // Expected result: 39
);