Seek and Destroy Help

Seek and Destroy Help
0.0 0


Having trouble filtering all required values. The return in my stripArr function is preventing me from iterating though all values that need to be tested. Thanks for the help!

function destroyer(arr) {
// Remove all the values

var arg =;

var arg1 = arg.shift();
//Turns arguments into arrays. Seperate them so I can test them.
function stripArr(val) {

for (i = 0; i < arg.length;i++) {
  if (val === arg[i]) {
    return false;
  } else {
    return true;


return arg1.filter(stripArr);

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


It is not iterating through all the values, because when a value does match, you return immediately instead of checking other values. You are close to a solution. Think about the following scenario and hopefully it will help you have a better idea of how to proceed.

_If you find a match, you need to return the value false immediately so the filter does not keep it. You only want to return true after you have gone through all the values in arg, so there is a different place the return true statement should go.


Figured it out. Makes perfect sense! Thanks a lot!