Tell us what’s happening:
Describe your issue in detail here.
I’m so so confused. I don’t even know what to do any longer… I checked through the solutions from the hints provided but I still could not understand any of the solutions. Its like none of the topics treated have covered enough to solved this particular problems. I need help pls!!! Your code so far
function destroyer(arr, item) {
for (let i = 0; i < arr.length; i++) {
if (arr.indexOf(item) >= 0) {
arr.splice(item[i], 1)
}
}
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/115.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Seek and Destroy
You shouldn’t change the function definition. It should be:
function destroyer(arr) {
You would then use the arguments object to access the remaining arguments passed in after arr. If you want to see what the arguments object looks like then add console.log(arguments) as the first line of the function.
I would recommend you turn the arguments object into an array to make it easier to work with. There are several ways to do this:
Also, it is best not to change the array passed into the function but rather create a new array with only the values you want to return from the function. You can think of it as applying a “filter” to the array passed in that only allows the values you want to be returned to go into the new array you are going to return (that was a hint on how to do this by the way )
P.S. I do see that one of the solutions in the hints changes the definition of the function to capture the remaining arguments passed into the function. While this goes against the instructions, it is actually the preferable method (instead of using the arguments object) so if the tests let you get away with it then I would use that method.