Seek & destroy solution not working

Hey guys, I feel as though this solution could work but it’s not, can you guide me to the right direction?

TypeError is: Cannot read property ‘apply’ of undefined

  **Your code so far**

// set arguments in function regardless of how many?
function destroyer(arr, ...args) {
// concat and filter through arr to remove what is included in arguments 
return arr
  .concat(...args)
  .filter(item => item.includes(...args));
}

console.log(destroyer(["tree", "hamburger", 53], "tree", 53));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36.

Challenge: Seek and Destroy

Link to the challenge:

I feel like this is backwards. You are checking if a single array item contains all of the other destroyer args?

Ah I guess not all but any destroyer args correct? I’m not sure how else to create that since some have 2 args some 3 etc

Unless I should loop through ...args and then run filter on arr using ...args[i]?

an other issue is that includes accept one single parameter, using ...args only the first item is passed in
also, is item an array?
and why you are including the elements in args inside the arr array?

Do you want all of the args included in the item or the item included in all of the args?

If you mean want as in want to filter out then I want to filter out the args in the array and return the array.

Ok I guess I’d rather do one issue at a time though because I believe I now have 4 questions in front of me

You should use includes as someList.includes(thisThing)

I know you hate MDN, but it’s useful to look up how the function works somewhere

  1. Array.prototype.includes() - JavaScript | MDN
  2. JavaScript Array includes() Method

ignore the last one, all the others are for this line

trying to understand what you want to do with it and what you think it is doing

I do still check MDN actually. I used this for the previous problem and it worked I’m not sure why it may not here.

For example I thought it’d check to see if “tree” (from arr) included “tree” (from args) then if so filter it out.

Right, but that’s backwards of how the documentation says the includes function works. includes checks if

let thisList = ['a', 'b', 'c'];

includes

let thisThing = 'd';

via

console.log(thisList.includes(thisThing));

I don’t know why I’m not seeing how. Wouldn’t it be filtered out if it returns true?

const array1 = [1, 2, 3];

console.log(array1.includes(2));
// expected output: true

When I look at this: .filter(item => item.includes(...args));
I read filter item where item includes args

item is one thing

...args is many things

The semantics is many.includes(one)

Right yeah I see that issue but does that mean by nature I can’t use includes at all or that I can tweak something and use includes still?

Earlier I mentioned if this could work

Welp I tried this but it’s not working because it says item.includes is not a function


let newArgs = [...args];
  for (let i = 0; i < newArgs.length; i++) {
    arr.filter(item => item.includes(newArgs[i]))
  }

you can use includes but you need to figure out how, like, what array you want to use it on?

Doesn’t filter go through each item in arr? Unfortunately I’m not understanding this

yes, so item is not an array, and includes can be used only on an array

what’s the array here?

arr but when I try that it doesn’t filter correctly

but arr is not here:

and you want to check if the single item is to remove or not (equals one of the elements in args)

What do you mean?

So for this I’m saying I tried the loop here