Https://www.freecodecamp.org/challenges/seek-and-destroy

Continuing the discussion from [freeCodeCamp Algorithm Challenge Guide: Seek and Destroy]
Please explain to me what am I doing wrong here?

function destroyer(arr) { var final=[];  var  temp=[];    
                         for(var  j=1;j<arguments.length;j++){
                           temp.push(arguments[j]);
                          }  
  // Remove all the values
  return arr.filter(function(val){
     return  temp.indexOf(val==-1);
   
     
  });
}


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

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums

You have a problem here, you aren’t comparing the result of indexOfwith the val but trying to get the index of the coercion of val == -1, in fine you are returning return temp.indexOf(false)

Could you then explain how to solve this problem using indexOf()?
Thankyou

You aren’t far from the solution :stuck_out_tongue:

str.indexOf(value) returns -1 if the value is not in, its index otherwise
So you need to compare this result return temp.indexOf(val) == -1, more like a typo problem :slight_smile: