How do I write a function which can be called several times in a row with one parameter? Here is an example:
function sum(a) {
// what should here?
}
sum(1)(2) // should return 3
How do I write a function which can be called several times in a row with one parameter? Here is an example:
function sum(a) {
// what should here?
}
sum(1)(2) // should return 3
Return another function that when called sums the argument of the first and the second like this:
function sum(a) {
return b => a + b
}
console.log(sum(1)(2))