我在比較兩個數組的元素並過濾出匹配值時遇到了一些問題。我只想返回不包含在wordsToRemove
之內的數組元素。使用.filter比較兩個數組並返回不匹配的值
var fullWordList = ['1','2','3','4','5'];
var wordsToRemove = ['1','2','3'];
var filteredKeywords = fullWordList.forEach(function(fullWordListValue) {
wordsToRemove.filter(function(wordsToRemoveValue) {
return fullWordListValue !== wordsToRemoveValue
})
});
console.log(filteredKeywords);