Here is code blow to return it's value.
function sum(a){
return function(b){
return a+b;
}
}
sum(2)(3);
It returns 5 but if I type code:
function sum(a){
function add(b){
return a+b;
}
return add(b);
}
It doesn't return expected value 5. I don't even understand how sum(2)(3) calls function. Any explanation for this is very much appreciated.