Seek and destroy task

**Tell us what's happening:**
Describe your issue in detail here.

i see 1,2,3 in my console instead of 1,1. what did i miss??
    **Your code so far**

function destroyer(arr) {
 return arr.filter((value, 
        index) => arr.indexOf(value) === index);

console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
**Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0

Challenge: Seek and Destroy

Link to the challenge:

Basically what you have there will just delete duplicates in an array. The real problem is you are not using the other arguments that are supposed to be used to deleted items from the array. If you look at destroyer([1, 2, 3, 1, 2, 3], 2, 3) you have an array, then two numbers. You need to use those two numbers to check the array. And it might be more then two numbers.

how do i use the two nuumbers to check an array??

Thats the part you need to figure out. The test gives a hint on how to use them.

Note: You have to use the arguments object.

i trie rewriting my codes .this time short and cleaner.

function destroyer(arr) {
  let args = [...arguments]
   return  arr = arr.filter(v => v < 2)


console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));

why are my not passing all the test??

You seem to be hung up on producing results to your very specific example, instead of writing a function that will solve every problem. You’re trying to just remove any number greater than 1, but that wasn’t the question.

So the problem says you’ll be given an array, and then any number of numbers to remove from that array. For example:

destroyer ([2, 5, 8, 3, 7], 3, 5);

So, this is asking you to take array [2,5,8,3,7] and remove the numbers 3 and 5… but you didn’t know how many removal numbers you were going to be given or what they are, so first thing you’d want to consider doing is finding that out… thats what your arguments are for. Once you find out what you need to remove, then you can go through the array and removing whatever numbers were given you to remove. Does that makes sense?

1 Like