Hello,
A few questions -
- The instructions open with the following sentences:
“Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum.”
My first question: returns the sum of what? i.e., if the function is to sum two arguments, but only one argument is provided, what would be the sum of the single argument, which I presume would be a single number? are we simply providing the value of the single argument as the sum? If not, what would we be summing together?
Further down in the instructions, I do see the following:
“Calling this returned function with a single argument will then return the sum:
var sumTwoAnd = addTogether(2);
sumTwoAnd(3)
returns 5
.”
However I am not clear if this is the sum to which they are referring above.
- Also, when I try to call the following “functions”:
addTogether(2)(3)
and
addTogether(2)([3])
I get a TypeError: addTogether(…) is not a function which I guess would make sense since there are two sets of parentheses, so to my novice eyes they don’t look like the JS functions I’m used to seeing.
My second question: how do you call a function that is not a function, in order to test these cases?
- The final sentence of the instructions state,
“If either argument isn’t a valid number, return undefined.”
My third question: what is considered a valid number? An integer? a non-negative number? typeof is number? not NaN?
Thanks in advance for taking a look at this, and for your willingness to help.
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
.
Challenge: Arguments Optional
Link to the challenge: