I am trying to splice all instances of some defined value from an array.
filterfunc: function(anyArray){
for(var i = 0; i <anyArray.length; i++){
var v = anyArray[i];
for(var j = 1; j <arguments.length; j++){
if(v == arguments[j]){
anyArray.splice(i,1);
}
}
}
return anyArray;
},
I pass an array along with the arguments that I don't want.
The problem I encounter is that the splice function does not splice all instances of the value.
ex: filterfunc([1,2,2,2,3,3,3,4,5,6],2,3);
the result: [1,2,3,3,4,5,6]
I want it to return [1,4,5,6]