如何在 JavaScript 中重复相同的短代码

How to repeat the same short code in JavaScript

   if (
     titleValue.toUpperCase().indexOf(filter) > -1 ||
     sepiValue.toUpperCase().indexOf(filter) > -1 ||
     discValue.toUpperCase().indexOf(filter) > -1 ||
     dateValue.toUpperCase().indexOf(filter) > -1
   ) {
     movieCard[i].style.display = "";
   } else {
     movieCard[i].style.display = "none";
   }

** 我想在代码语句中缩短这段代码 ||**

我想在此代码中使用 dry consent,请大家帮忙?

你怎么看:

const hasFilter = [titleValue, sepiValue, discValue, dateValue]
  .find(item => item.toUpperCase().indexOf(filter) > -1);

movieCard[i].style.display = hasFilter ? "" : "none";