Seek and Destroy - help my find the fault in my logic

Tell us what’s happening:

Your code so far

function destroyer(arr) {
  // Remove all the values
  var filterFunc = function(val){
    for(var i = 1; i<arguments.length; i++){
     if(val ==arguments[i]){
       return false;
    return true;
  arr = arr.filter(filterFunc);
  return arr;

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/60.0.3112.113 Chrome/60.0.3112.113 Safari/537.36.

Link to the challenge:

i’d say your problem is pretty interesting, nothing’s wrong with your logic. I finally able to find the problem after check the value of each element

    for(var i = 1; i<arguments.length; i++){
     if(val ==arguments[i]){

arguments[i] is your problem.
It seems in that function, the value of the argument change.
this is the value of argument outside the function :
arguments[0] = [1, 2, 3, 1, 2, 3];
arguments[1] = 2;
arguments[2] = 3;

this is the value of argument inside the function :slight_smile:c;
arguments[0] = [1,2,3,1,2,3]
arguments[1] = [0, 1,2,3,4,5]
arguments[2] = [[1,2,3,1,2,3],[1,2,3,1,2,3],[1,2,3,1,2,3],[1,2,3,1,2,3],[1,2,3,1,2,3],[1,2,3,1,2,3]]

what can you do ? you can store the value of the argument in a global array, and instead of use this :

for(var i = 1; i<arguments.length; i++){
     if(val ==arguments[i]){

you replace arguments with array. It works, you can try it by yourself

Thanks a lot for the help.

@alta9 I’m a noob so I’m just guessing. Could the cause of that problem be that she refers to the ‘arguments’ object inside of filterFunc, which in turn is being called by the filter prototype? Might this mix up which arguments are being referred to by the ‘arguments’ object?

Anyway, you should append “-SOLVED” to the title of this (or at least “- PROBLEM FIXED”)

arguments[0] = [1,2,3,1,2,3] -> Array Input
arguments[1] = [0,1,2,3,4,5] -> Array Input’s element, (6)
arguments[2] = [[1,2,3,1,2,3],[1,2,3,1,2,3],[1,2,3,1,2,3],[1,2,3,1,2,3],[1,2,3,1,2,3],[1,2,3,1,2,3]] ->6 element of array input

well, you might be right. every argument in that function has correlation with the input. The function might automatically create argument based on input. If that’s the case, global argument can’t beat local argument in their own function