I wondered if I could get some help with my code. I don’t understand why my variable ‘output’ is logging the following to the console:
1
1,2
1,2,3
1,2,3,1
1,2,3,1,2
1,2,3,1,2,3
Here is my code in full:
function destroyer(arr) {
// Remove all the values
let args = Array.prototype.slice.call(arguments);
let newArr = args[0];
let newArgs = args.slice(1);
let output = [];
for (let i = 0; i < newArr.length; i++) {
if (newArgs.indexOf(newArr[i] === -1)){
output.push(newArr[i]);
console.log(output);
}
}
return output;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);