With my code as it is, I’m passing every test except:
“addTogether(2, “3”) should return undefined.”
Can I please get a hint as to what I should look into? I tried adding another “if else” statement that would return undefined if num1 is a number and num2 is not a number, but that didn’t work. I also know that generally chaining together else if statements isn’t really good practice.
I tried to utilize the “arguments object” method but wasn’t sure how to make it work for me.
Your code so far
function addTogether(num1, num2) {
if (typeof(num1) === "number" && typeof(num2) === "number"){
return num1 + num2
} else if (typeof(num1) !== "number" && typeof(num2) !== "number"){return undefined}
else return function(y){
if (typeof(y) === "number"){
return num1 + y;} else return undefined
}
}
var result = addTogether(2)(3);
console.log(result)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36.
(typeof(num1) !== "number" || typeof(num2) === "string")
It’s all in this line here. You check if num1 is something other than a number, which is good.
But why do you check if num2 is specifically a string?
Always happy to help! Now take some time to celebrate your success! You went above and beyond, and instead of just focusing on making your function pass the tests, you made it pass more potential user inputs. Nice work!