Some arguments seem not to be accessible in function

Some arguments seem not to be accessible in function
0

#1

I’m stuck on Seek and Destroy: https://www.freecodecamp.com/challenges/seek-and-destroy I can’t see how to access the parameters after the first one. If I add no code other than a console.log(arr); I only see the array, not the 2nd & 3rd parameters. I.e.

function destroyer(arr) {
  // Remove all the values 
  console.log(arr);  // just shows [1, 2, 3, 1, 2, 3]
  return arr;
}
destroyer([1, 2, 3, 1, 2, 3], 4, 5);

What happens to the 4, 5? I need them in the function to know what to remove, but can’t see them.


#2

All arguments passed to a function are stored in the arguments array. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments.


#3

when you have more arguments than parameters … like in your case here you have the arguments method.
so if you console.log(arguments) you get array of all of them … if you console.log(arguments[1]) you get [4,5]


#4

Ah, thanks, I was trying arr[1], based on the MDN description, where I read ‘argument’ as referring to whatever name the argument had, instead of literally argument.

Thanks both of you.