Seek and Destroy. Here's my code so far

Tell us what’s happening:
I’m trying to delete the numbers in the array that equals to the numbers out of the array.

Your code so far


 function destroyer(arr) {
     let args = [].slice.call(arguments);
 
     for(let i = 0; i < args.length; i++) {
         for(let j = 0; j < args[i].length; j++) {
           if(args[i][j] === args[i]) {
             delete args[i][j];
           }
         }
         return args[0];
     }
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy

Hi,

args is equal to [ [ 1, 2, 3, 1, 2, 3 ], 2, 3 ] Are you sure that’s what you want to loop over in your outer loop?
I suggest that you break out the arguments into named variables at least during testing to make them easier to keep up with.

delete does remove an element from the array but it leaves a hole filled with undefined

You might do better to create an results array and push the ‘keeper’ elements onto that as opposed to removing items from an array.

Good luck