Intermediate Algorithm Scripting - Seek and Destroy

Tell us what’s happening:
I’m 100% lost here. I’ve got no idea what the challenge wants me to do as it says " Note: You have to use the arguments object."

I do realize I have to use numbers 2 and 3 as arguments to be passed into the destroyer.

As far as I know arguments after the array cannot be hard coded into destroyer function as there could be one or more of arguments to be passed in.
How can I pass something into the destroyer function without it being an argument?

I also can’t remember neither find any exercises that even remotely resemble this one.

Your code so far

function destroyer(arr) {
  
  console.log(arr)
  


  return arr;
}

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


Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Seek and Destroy

Link to the challenge:

This is what I get when I Google “MDN arguments object”

There is another way to handle this though. Do you remember this challenge:

So arguments is an object that behaves pretty much like an array and has all the arguments of a function call stored in it.

And the challenge above with ...args uses the same functionality as arguments but it only has “unused” arguments stored in it, right?

1 Like

Yup.

Depends upon what you mean by ‘unused’. It has ‘the rest’ of the arguments after any you specifically declare.

This is exactly what I meant by unused. Just couldn’t find the right wording for it.

I believe I have the necessary information of arguments and ...args to give the challenge a go.

Thank you a lot!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.