Skip to content

Instantly share code, notes, and snippets.

@ArielLeslie
Created October 6, 2015 17:32
Show Gist options
  • Save ArielLeslie/3458da987b08bc23a5f7 to your computer and use it in GitHub Desktop.
Save ArielLeslie/3458da987b08bc23a5f7 to your computer and use it in GitHub Desktop.
Arguments Optional
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