Can I get some help for the Seek And Destroy challenge?

function destroyer(arr) {
 
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);

How would I access the values outside of the array? In this case the 2, 3, and 5. Thanks

All arguments passed to function are stored in arguments variable.

Arguments object

And how would I access them?

arguments[0] // [3, 5, 1, 2, 2]
arguments[1] // 2

As arguments is not array, but array-like object, you can’t use array’s method like slice.

To convert arguments to array, use

var args = Array.prototype.slice.call(arguments);

To get all arguments except first one using slice method:

var args = Array.prototype.slice.call(arguments, 1);

“Similar” to how you access an array.

function myFuntion() {
  for (var i = 0; i < arguments.length; i++) {
    console.log(arguments[i]);
  }
  return arguments.length;
}

myFunction(10,20,30,40,50);

}

The above function returns 5 and displays the following to the console:

10
20
30
40
50