function add() { if(typeof arguments[0] === "number" && typeof arguments[1] === "number"){ return arguments[0] + arguments[1]; }else if(arguments.length === 1 && typeof arguments[0] === "number"){ var x = arguments[0]; return function(y){ if(typeof y === "number"){ return y + x; } }; } }