Tell us what’s happening:
Hi everyone,
Even though this code worked as wanted, I couldn’t understand the logic under the Array.prototype.includes() method.
I indicated the array the one I want to work on it with the name of ‘list’. However, I did not specify the variable in the Array.prototype.includes() method, which is ‘val’. So, how did the JS understood the value of the variable as the ones comes after the arguments[0].
I’m a newbie learner, so do not hesitate to correct me in terms of terminology that I used, and thanks for your answer.
Your code so far
function destroyer(arr) {
let list = arguments[0];
return list.filter(val => !Object.values(arguments).slice(1).includes(val));
}
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_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
.
Challenge: Seek and Destroy
Link to the challenge: