Tell us what’s happening:
Describe your issue in detail here.
Hi, I’m passing most of the tests for this challenge, but I’m just stuck on how to account for numbers outside of the function(). (I’m still new to using these terms, so feel free to correct me as you help me out - thanks so much!)
As you can see in my code, for the function addTogether, if the arguments passed into the function are greater than 1 and if they are both numbers, the function runs and adds them together - if that’s not the case, it returns undefined. That works correctly.
Where I’m stuck are these problems here:
- addTogether(5)(7)` should return 12
- addTogether(2)([3])
should returnundefined`
I’m not sure how to account for/place inside both of the numbers because they are sitting next to one another, but with the current placement of the (7) and the ([3]), I can’t access them inside of the addTogether function.
Any guidance appreciated, thank you!
Your code so far
function addTogether() {
let firstArgument = arguments[0];
let secondArgument = arguments[1];
if (arguments.length > 1 && typeof firstArgument === "number" && typeof secondArgument === "number"){
return firstArgument + secondArgument
} else {
return undefined
}
}
addTogether(5, 7)
let endResults = console.log(addTogether(5, 7))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Arguments Optional
Link to the challenge: