Tell us what’s happening:
I really don’t see atm why this doesn’t work…obviously I’m doing sth wrong.
I thought about a nested for loop at first but then went this way.
When I console.log(args[i])
in the loop i get the value 2 and 3 but later in the filter it seems 2 is being skipped somehow and its returned as well.
Thanks for any help
Your code so far
function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);//convert to array
console.log(args) //test
for (let i = 1; i < args.length; i++) {
//console.log(args[])// test inside loop
arr = args[0].filter(word => word != args[i])
}
//arr = arguments[0].filter(word => word != arguments[1] && word != arguments[2] && word != arguments[3]);// 3 Arguments Hardcoded
return arr ;
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));//output
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0
.
Challenge: Seek and Destroy
Link to the challenge: