Seek and destroy solution question

I was finally able to get my solution to pass. Originally I had a var answer = arr.filter(blah) under the args variable and it would return every number in the argument. It only worked when i removed that variable and just returned the filter at the end. I am not sure why it worked that way and not the other.

Can anyone shed some light on to why that is, It would be appreciated.
link to challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy/

function destroyer(arr) {

var args = []; // variable for arguments. returns [2, 3]

//loop to extract the arguments
for (var i = 0; i < arguments.length; i++) {
   if (i !== 0) {
     args.push(arguments[i]);
     
   }
   
}

//function to check if an array includes an item
function blah(item) {
 
if (args.includes(item) === false) {
  return item;
} 
}
 return arr.filter(blah); // returns filtered results

}

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

Share with us the version that wasn’t passing , otherwise it is not possible to answer


var args = []; // variable for arguments. returns [2, 3]
var answer = arr.filter(blah);

//loop to extract the arguments
for (var i = 0; i < arguments.length; i++) {
   if (i !== 0) {
     args.push(arguments[i]);
     
   }
   
}

//function to check if an array includes an item
function blah(item) {
 
if (args.includes(item) === false) {
  return item;
} 
}
 return answer;
}

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

You need to define blah before using it, I think

Also this is the callback of the filter method. What happens if your item is 0? It is not included even f returned. Why? Because it is a falsy value. Remember that filter expect a Boolean from the callback

Thats how I have to write the function if I want it to work with a 0?

Return a Boolean, which is what the filter method expect, not the item.

ok thanks for the tip.