Seek and Destroy improvements [SOLVED]

Seek and Destroy improvements [SOLVED]
0

#1

Tell us what’s happening:
Hello campers. This is the first time i’m asking for help. The code below works just fine and completes the challenge, but i’m repeating myself couple times so it’s not DRY. And it’s not “scalable”, if we had more arguments it wouldn’t work. I could just do it the easy way, but my intention is to learn properly. I tried to do this using “for loop” since i think it’d be the proper way, but i cannot figure out how to put all things together. I’m always getting “out of scope” warnings. Thanks in advance.

Happy coding,
Nic.

EDIT: Solved the problem.

Your code so far

function destroyer(arr) {
  // Old solution
/*  var a = arguments[1];
  var b = arguments[2];
  var c = arguments[3];
  var result = arr.filter (function (x){
    return x !== a && x !==b && x !==c;
  });
  return result; */

 // New solution
  var arg = Array.prototype.slice.call(arguments, 1);
  return arr.filter (function (x){
    return arg.indexOf(x) < 0;
  });
  
  
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36.

Link to the challenge: