Bug in the tests for "Seek and Destroy"... or in my code? [SOLVED]

Bug in the tests for "Seek and Destroy"... or in my code? [SOLVED]
0.0 0

#1

Outputs ["hamburger"] and all of the other expected output arrays in the test window… but displays all tests as having failed. Is this a problem with the testing or with my code?

function destroyer(arr) {
  // Remove all the values
  
  function destroy(el) {
    return el !== this;
  }
  
  
  for (i=1;i<arguments.length;i++) {
    arr = arr.filter(destroy, arguments[i]);
  }
  
  return arr;
}


destroyer(["tree", "hamburger", 53], "tree", 53);

#2

I just ran your code on my machine and got [ ‘tree’, ‘hamburger’, 53 ] as an output.


#3

Huh, that’s weird. If I run it from the console, it does indeed give the original array. So I guess the answer is that there’s a bug in both the tests and my code. Back to the drawing board, then…


#4

Finally solved it:

function destroyer(arr) {
  // Remove all the values
   
  var argArray = [];
  for (var i=1;i<arguments.length;i++) {
     argArray[i-1] = arguments[i];
  }
  
  function destroy(el) {
    return argArray.indexOf(el) === -1;
  }
  
  arr = arr.filter(destroy);
    
  return arr;
}

Still can’t quite work out what was wrong with my original (failed) solution, though. Am I missing something really obvious?