Tell us what’s happening:
Hi everyone,
I was doing this project, I arrived to do it till the end of the loop but after this I was facing a problem to show the results, after differents tries I went to the solution and I still don’t understand how works the ‘arr.filter(Boolean)’
Can someone could try to explain me how it works in differents words than the one given in the solution ?
Appreciate
Your code so far
Code Spoiler
function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < args.length; j++) {
if (arr[i] === args[j]) {
delete arr[i];
}
}
}
return arr.filter(Boolean);
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy