I'm trying to filter out the values of one array from another array. When using Javascript's filter method, my script looks like this.
var notUsed = ["Advanced Tac. Training Area", "Dunbarton Railroad Yard"];
var areas = ["A Area", "Advanced Tac. Training Area", "B Area", "Dunbarton Railroad Yard", "C Area"];
areas.filter(function(){
return areas = notUsed;
})
console.log(areas);
According to the documentation, when I console the areas array after I've run the filter function, the array should look like this
"A Area", "B Area", "C Area"
However, that's not what's happening. Instead, I'm getting the values of the notUsed array, so it's essentially replacing the areas array with the notUsed array. Can anyone explain why this is happening and how I go about getting the areas array without the values of the notUsed array?
If this question has already been asked, please let me know in the comments and link to the answered question. that way I can delete this one and eliminate the duplication.