Hello. Could someone tell me why the following code doesn’t pass the third and fourth tests?
destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return [1].
destroyer([2, 3, 2, 3], 2, 3) should return [].
function destroyer(arr) {
let args = Array.from(arguments).slice(1);
for (let i = 0; i < args.length; i++) {
for (let j = 0; j < arr.length; j++) {
if (args[i] === arr[j]) {
arr.splice(j,1);
}
}
}
return arr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);