I was attempting to use .forEach to remove the contents of one array(ignore) from another array(input).
As an example in the below I would expect the input array to contain "b" and "h" however it contains "g" and "h" when I run this.
curious why I am not getting my expected results and if this is a good method.
var input = ["a", "b", "g", "h"],
ignore = ["b", "h"];
var newInput = function(element, index, array){
if (input.indexOf(ignore[index]) > -1){
input.splice((ignore[index]), 1)
}
}
ignore.forEach(newInput);
ignore[index]is precisely equal toelement, right? You can't pass the element tosplice, you have to pass the position.