# Intermediate Algorithm Scripting: Seek and Destroy_Help Please

I wondered if I could get some help with my code. I don’t understand why my variable ‘output’ is logging the following to the console:

1

1,2

1,2,3

1,2,3,1

1,2,3,1,2

1,2,3,1,2,3

Here is my code in full:

``````function destroyer(arr) {
// Remove all the values
let args = Array.prototype.slice.call(arguments);
let newArr = args[0];
let newArgs = args.slice(1);
let output = [];
for (let i = 0; i < newArr.length; i++) {
if (newArgs.indexOf(newArr[i] === -1)){
output.push(newArr[i]);
console.log(output);
}
}
return output;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
``````
``````(newArgs.indexOf(newArr[i] === -1))
``````

Look at where your parentheses begin and end. Is it doing what you want it to?

`if (newArgs.indexOf(newArr[i] === -1)){`

should be

`if (newArgs.indexOf(newArr[i]) === -1){`

Thanks so much! I completely missed that.

Let’s see this line, from inside out.

`newArr[i] === -1` is `false`
`newArgs.indexOf(false)` is `-1`
And as `-1` is truthy, the code inside the if statement is always executed, resulting in all the elements in `newArr` being pushed to `output`

Can you figure out how to fix this?