Javascript function challenge add(1,2) and add(1)(2) both should return 3
JavaScript (as asked)
This is a &quot;correct&quot; way to do it but hardly the golfiest way. It's unclear if you're asking for shortest code (the question looks like it will be closed soon anyway.)
function add(a, b) {
    if(typeof b === &quot;undefined&quot;)
        return function(c) { return a + c }
    return a + b
}