What I mean is if I create a function add and I run add with one parenthesis it return the argument of add e.g. add(2) returns 2. If run with two parentheses it returns sum of their argument e.g. add(2)(8) returns 10.
How do I test if there is (8) and work on the (8)?
add(2) returns 2. add(2)(7) returns 9. add(2)(7)(11) returns 20.
All I could do is for the first one which is just
function add(num) {
return num;
}
The add function is some sort of higher order function that can take any number of new parentheses. add(1)(2)(7)(10) = 10. How do I achieve for others?