# Intermediate Algorithm Scripting - Seek and Destroy

Tell us what’s happening:
Describe your issue in detail here.
I have no idea how to visualise the steps by step solution for this problem … Can anyone help me with it ? I dont want to look at solution .

``````function destroyer(arr) {
return arr.filter(arguments);
}

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

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

Challenge: Intermediate Algorithm Scripting - Seek and Destroy

Have you come up with any ideas to tackle this step-by-step? If you could share those then we could help steer you in the right direction. All I can say now is you’ll definitely need some loops to iterate through the lists.

1 Like

i only have a light idea that if i can somehow split arguments object in two parts, i can then check every element of second part to the first part of the split and then i can return the non equating elements to be put in a new array and then return the new array … I dont know if i am right ?

can i use arguments .slice() for splitting

Unfortunately the arguments object does not inherit from the Array prototype so it doesn’t have a slice method available. However, you can turn it into an array to be able to slice it!

``````function brokenExample() {
arguments.slice() // this will error
}

function workingExample()
Array.from(arguments).slice() // this will work
}
``````
1 Like

just a doubt why i cannot use splice… Also i made this code … can you tell if it is this going somewhere ? i dont know what to put in if so that i can return non equating elements

``````let splitArr = Array.from(arguments).splice(1)
for (let element in arr){
if(){
newArr.push(element);
}
``````

Be careful, `splice` and `slice` are different methods with different behaviors so make sure you’re using the correct one.

Since you have two lists, you might need to have two loops.

1 Like

My Code Till Now :

``````function destroyer(arr) {
let splitArr = Array.from(arguments).splice(1);
let newArr=[];
for (let element of arr){
if(splitArr.indexOf(arr) === -1){
newArr.push(element)
}
}
return newArr;
}

console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
``````

You’re really close.

It looks like you’re not using the `element` variable.

1 Like

Oh Thank You So Much fo the help … i did it …

Good job! I think you should have a look at the solutions now because there are a handful of different ways to tackle this problem.

1 Like

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