Created
October 6, 2015 17:32
-
-
Save ArielLeslie/3458da987b08bc23a5f7 to your computer and use it in GitHub Desktop.
Arguments Optional
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add() { | |
var first = arguments[0]; | |
if (arguments.length == 1 && typeof first === "number"){ | |
return function(x){ | |
return add(first, x); | |
}; | |
}else if (arguments.length == 2 && typeof first === "number" && typeof arguments[1] === "number"){ | |
return first + arguments[1]; | |
}else{ | |
return undefined; | |
} | |
} | |
add(2,3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment