Tell us what’s happening:
This was the answer I landed on, though I only was able to figure it out by console.log’ing each step of the way. What’s not intuitive to me is why “console.log(arr)” is only [1, 2, 3, 1, 2, 3], when I would expect it to be [1, 2, 3, 1, 2, 3], 2, 3? Is it the case that if only one argument is supplied in your function, it will be assigned to only the index 0 argument?
Apologies if this seems like a basic question, I didn’t see anyone else with a similar one.
Your code so far
function destroyer(arr) {
var args = Array.prototype.slice.call(arguments, 1)
console.log(args)
console.log(arr)
return arr
.filter(value => !args.includes(value));
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
.
Challenge: Seek and Destroy
Link to the challenge: