Seek and Destroy - for loop inside of the function

Seek and Destroy - for loop inside of the function
0

#1

Hey. I’ve done Seek and Destroy algorithm challenge, but I’d like to make a for loop inside of the function to make it flexible. Could you give me a hint how to do that? Code’s below:

function destroyer(arr) {
  var arrInitial = arr.slice.call(arguments); //from arguments to array
  var arrFrom = arrInitial[0];
  var toDelete = arrInitial.slice(1); 
  var positions = arrFrom.filter(function(number) {
    return number !== toDelete[0] && number !== toDelete[1] && number !== toDelete[2];
  });
  return positions;
}

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

#2

You want a for-loop that checks each number in toDelete if that number equals the current number in positions. If it found such a number, you’ll immediately return false. If you never found one, return true at the end.