Seek and Destroy

Hey,

I got this to work using .filter(). Just wondering why using .map() returns boolean values.

Thanks!

function destroyer(arr) {
  for (let i = 1; i < arguments.length; i++) {
    arr = arr.map(num => num !== arguments[i]);
  } 
    return arr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);     

Because this expression gets evaluated as either true or false. map creates a new array of elements using the return value of the callback function supplied. In this case, it is just a Boolean.

1 Like

Got it. Thanks for answering!