Seek and Destroy Algorithm

Seek and Destroy Algorithm


I have written an algorithm that returns all the correct outpunt yet I can not proceed to the next challenge. What is going on? Can someone please look at my code. The output comes out OK. But
the challenge says its incorrect.

My code:

function destroyer(arr) {
function isequal(value) {
return value !== this;}
filtered = arguments[0];
for (i=1; i<arguments.length; i++){
filtered = filtered.filter(isequal,arguments[i]);
return filtered;

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


Hi. This could be a bug. I tried your code in and it produced a different output.

For this to pass, you have to add 'use strict'; at the beginning of your destroyer function. Then add var before filtered = arguments[0]; and i=1 (don’t forget this when declaring variables!).

When I examined the value of this, I got this weird object: { '0': 't', '1': 'r', '2': 'e', '3': 'e' } instead of just 'tree'. I honestly have no idea why this is so, but it does become 'tree' at strict mode.

Sorry this turned out to be confusing. I’m confused about this myself! Maybe others at the forum can make this clear. You may want to come back to this challenge one day and submit a simpler solution.


For some strange reason your code dose what is should do on freecodecamp but the reality is it dosent work … try it on or paste into the developer tools console and you will see it just returns the 123123… as far as im aware filter takes only one function as a parameter eg isequal … in your case the other parameter is ignored. so you need to redo the isequal function to get your result…
from looking at your code i believe you dont use the developer tools to debug your code when you have a problem. I think if you use the developer tools or you will see what is going on in your code and will make things easier for you to understand whats going on and how to fix it.
if you do this and still have a problem post again.