Arguments Optional- Second argument can't be accessed on final test

Arguments Optional- Second argument can't be accessed on final test
0.0 0

#1

Tell us what’s happening:
On the last test, where the second argument is an array with a number, I’m not able to verify that the second argument exists at all, let alone work with it in order to pass the test.

I am logging the second argument to the console and, for that last test, the console says “undefined” as if there is no second argument at all. Is this a bug?

Ignore all of the code everything except:

console.log(arguments[1]);.

This isn’t a complete attempt. I am specifically just asking why the second argument can’t be accessed in the test where the second argument is ([3]).

Your code so far


function addTogether() {
  let nanz = function(x) {return isNaN(x);}
  let arr=Array.from(arguments); 
  console.log(arr,arguments[1]);
  if (arr.some(nanz)) {return undefined;}
}
addTogether(2,3);

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional


#2

You are not passing the last one for a similar reason you are not passing the 2nd argument. The instructions state:

If only one argument is provided, then return a function that expects one argument and returns the sum.

Where in your code are you returning a function when only one argument is provided?


#3

Adding on to the previous posts, isNaN() doesn’t check if given argument is a number or not. It only checks if the given argument is NaN or something else.


#4

Ignore everything except:

console.log(arguments[1]);.

This isn’t a complete attempt. I am specifically just asking why the second argument can’t be accessed in the test where the second argument is ([3]).


#5

Because in the test case of addTogether(2)([3]). There is only one argument being passed to addTogether which is the number 2. The ([3]) after the (2) is a separate call to a function. That is why you have to return a function for the addTogether(2) call, so that the function returned will call with [3] as an argument.