Arguments Optional


#1

This test is not working properly. Let me prove it.

Place this code in the function:

 if(true){
    return undefined;
 }

Three cases are suppose to return undefined:

addTogether(“http://bit.ly/IqT6zt”) should return undefined.
addTogether(2, “3”) should return undefined.
addTogether(2)([3]) should return undefined. < -------- fails.

The last case fails to accept the undefined. I have been working on this for three days now,
I can follow up by posting my code. I have it set up so that it MUST return an undefined if either
parameter does not pass the typeof test, testing for ‘number’. Cannot proceed from here,
as there is no logical action left to take.

BTW, if you return 5, the test also fails on one outcome.


#2

the test case is fine - the test case is

addTogether(2)([3])

there are two function calls here - the first call is addTogether(2) - the second call is the function returned by addTogether(2) - the second call is passed the parameter [3]

what do you think happens for the second call if your entire definition of addTogether is

function addTogether() {
  if(true){
    return undefined;
  }
}

btw - the above is equivalent to having a completely empty function body

function addTogether() {
}

#3

The problem seems to be then that I cannot find were the JavaScript explanation of
this “first call and second call” phenomena then. I was viewing it as simply two
parameters because I could not find any examples or references to technical
info on a function that has (2)(3) this kind of thing following it.


#4

I think the problem statement for https://www.freecodecamp.com/challenges/arguments-optional is pretty clear about the two functions involved - I agree it is a conceptual leap from a single function call that returns simple values to a function that returns a function that is used immediately - maybe couple more exercises on functions as first-class objects are needed before this problem

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions


#5

Ok, I will look that over, thanks for the assistance!