Tell us what’s happening:
Why it won’t return undefined when i test:
addTogether(2,[3]);
but the code works when it gets to the same point with console.log
Code still return undefined for
addTogether(2, “3”)
Your code so far
function addTogether() {
if (typeof arguments[0]=="number"){
if (arguments.length == 1){
let a = arguments[0]
return function(b){
return(a+b)
}
}
else if(typeof arguments[1]=="number") {
return(arguments[0]+arguments[1])
}
else {
return undefined}
}
else {return undefined}
}
addTogether(2,[3]);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
.
Challenge: Arguments Optional
Link to the challenge: