Need Help - Arguments Optional Exercise

Tell us what’s happening:
Hi all, so I need some assistance understanding what this problem is asking. I understand the first half, of creating a function that adds two numbers, if they are both numbers, and if there is only one argument passed, then run a function. Where I get lost is when they say the returned function will be expecting a second number to add to the original number. If you run ‘addTogether(2);’ how is the function going to expect a second number, if there is only one passed in? I don’t understand what they are asking.

Your code so far

function addTogether(value1, value2) {
  if (typeof value1 === 'number' && typeof value2 === 'number'){
    return value1 + value2;
  } else {


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36.

Link to the challenge:

This is an advanced topic where you are expected to understand closure and currying.

JS functions can also return functions. Your first function should receive parameter/s then return a function. If it received one valid param, then it should return a function. The returned function then should also receive a parameter then adds its parameter with the previous parameter.

Additional explanation here.

1 Like

That was incredibly helpful, thanks so much @shimphillip. I was able to solve the problem, with not the prettiest code, but solved, nonetheless!

1 Like