Hi, could anyone take a couple minutes to explain why this doesn’t work? (Goal: Remove elements in initial array that are same value as subsequent arguments.)
function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
return args.filter(function(s){
return args[0][s].indexOf(args[1]) < -1;
})
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Train of thought: Turn argument functions into an array. Filter through first array element. Return each element within first array that is false for second element. One it’s working I’ll pop in a for loop to check the rest of the elements.
Type error: Cannot read property ‘indexof’ of undefined. Really quite stumped by this.
Thanks in advance.