Seek and Destroy problem to understand

Tell us what’s happening:
Hi everyone,
I was doing this project, I arrived to do it till the end of the loop but after this I was facing a problem to show the results, after differents tries I went to the solution and I still don’t understand how works the ‘arr.filter(Boolean)’
Can someone could try to explain me how it works in differents words than the one given in the solution ?

Your code so far

Code Spoiler

function destroyer(arr) {
  var args =;

  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < args.length; j++) {
      if (arr[i] === args[j]) {
        delete arr[i];
  return arr.filter(Boolean);
destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Link to the challenge:

say you have an array arr and a function f that returns a truthy or falsy value (or just a boolean)

when you call arr.filter(f) it returns a new array containing only the elements for which the function returns truthy values (or true)

The problem we want to solve is to return a new array that doesn’t have any of the other arguments to destroyer in it

You can use filter like the solution suggests, or you can do this manually by creating and returning a new list yourself

more information on filter here:

1 Like

thank you your explanation made it clearer for me !