如何根据另一个数组中的单词过滤一个数组?

How to filter an array based on words in another array?

我想过滤一些包含在数组中的单词,包含在一个字符串中。例如:

输入

1. "disappear" 定义:

[ "Cease to be visible.",
  "Cease to exist or be in use.",
  "Be lost or go missing, become IMPOSSIBLE to find.",
  "Abduct or arrest and kill or detain (a person) for political reasons,
  without making their fate known." ]

2。禁用词:

[ 'without', 'impossible' ]

结果

[ "Cease to be visible.", "Cease to exist or be in use." ]

我想,我已经很接近答案了:

function filterDefinition (defs, badWords) {
  const definitionFilter = defs.filter(function(def) {
    if (def.includes(badWords || badWords.toUpperCase()) {
      return !defs
    }
  });
  return definitionFilter;
}

像这样?

function filterDefinition (defs, badWords) {
  return defs.filter(function(def) {
    return !badWords.some(badWord => def.includes(badWord) || def.includes(badWord.toUpperCase()));
  });
}

String.includes(string) 不适用于数组。