Hi coders!
Really struggling with the “seek and destroy” challenge in Beginning Javascript. This is what the challenge is about:
You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.
And this is my code so far…
function destroyer(arr) {
var args = arr.slice.call(arguments);
function remove() {
for (i = 1; i < args.length; i++) {
if (args[0].indexOf(args[i]) === -1) {
return false;
}
}
return true;
}
var filtered = args.filter(remove);
return filtered;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Could anyone point me in the right direction?
Thanks
Rossella