Intermediate Algorithm Scripting - Seek and Destroy

Tell us what’s happening:
Describe your issue in detail here.

Hi,

tried the code, it works in some cases, not sure why its not working for the other cases to pass the test.

Could you please help.

Thanks

Your code so far

function destroyer(arr, ...args) {

    for (let i=0; i<arr.length; i++){

      for (let j=0; j<args.length; j++) {

        if (args[j] == arr[i]) {

          arr.splice(i, 1);

        }

      }

    }

  console.log(args)

  return arr;

}

console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Seek and Destroy

Link to the challenge:

Splice changes the contents of the array. That leads to buggy and confusing results when used in a loop

Hi JeremyLT,

Thank you for pointing this out.

Grateful.

Thanks