Why is this doesn’t satisfy
addTogether(2)([3])
should return undefined
.
it dose return undefined
and it already satisfied all the other conditions
function addTogether() {
if(typeof(arguments[0])=== "number"){
if(arguments.length !== 2){
return ((y) => {return arguments[0] + y});
}
if(arguments[1] !== undefined && typeof(arguments[1]) === "number"){
return arguments[0] + arguments[1];
}
}
return undefined;
}
console.log(addTogether(2,[3]));
console.log(typeof([3]));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Arguments Optional
Link to the challenge: