Skip to content

Instantly share code, notes, and snippets.

@cristofer-dev
Created June 24, 2017 22:23
Show Gist options
  • Save cristofer-dev/c66951f79a05e3b4c66131f73596fb28 to your computer and use it in GitHub Desktop.
Save cristofer-dev/c66951f79a05e3b4c66131f73596fb28 to your computer and use it in GitHub Desktop.
function addTogether(x) {
console.log("\n");
console.log("In function" + arguments.length);
if(arguments.length==2 && typeof arguments[0] === "number" && typeof arguments[1] === "number"){
var sum = arguments[0] + arguments[1];
return sum;
}else{
if(arguments.length==1){
var n1 = arguments[0];
console.log(n1);
return function(n){
console.log(n1);
console.log(typeof n1);
console.log(typeof arguments[0]);
if(typeof n1 === "number" && typeof arguments[0] === "number"){
var sum = n1 + arguments[0] ;
return sum;
}else{
return undefined;
}
};//function
}else{
return undefined;
}
} // if else
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment