I need to make the following (below) function call to give the same result in both situations:
sum(5,4); // 9 sum(5)(4); // this should also print 9
I tried the following but did not work:
function sum(x,y){ var a = x; var b = y; if (y == undefined && y == ''){ return function (a,b){ return a +b; } } else { return a +b; } }
Any suggestions?
source share