I can’t figure out how to erase all of the elements that match those outside the array in the arguments
object. Anyone got any ideas or hints?
Thanks.
Your code so far
function destroyer(arr) {
return arr.filter(elem => {
for (let i = 0; i < arguments.length; ++i) {
if (i >= 1 && elem === arguments[i]) {
arr.splice(arr.indexOf(elem, 1));
}
}
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/83.0.4103.116 Safari/537.36 Edg/83.0.478.64
.
Challenge: Seek and Destroy
Link to the challenge: