How to convert a normal filter to multi filter on Angular

I am trying to convert a filter into a multifilter on Angular 12 (TypeScript)

I tryed this...

resp.filter(((v) => v.toLowerCase().indexOf("'") > -1)&& ((v) => v.toLowerCase().indexOf("’") > -1))

...but doesn't works.

Is it possible?

Thanks.


Put your 2 conditions in the first callback :

resp.filter((v) => v.toLowerCase().indexOf("'") > -1 && v.toLowerCase().indexOf("’") > -1)

Notes :

  • it seems that toLowerCase is useless if you want to search ' or
  • I am not sure if you need a AND or a OR here. Depends of what you want to do. a OR seems more appropriate if I guess correctly what you are trying to do
  • indexOf > -1 surely works but now, javascript defines the function includes (from ES6) which will make the code more readable (think about the future you that will have to fix bugs in this code 6 months later)

I suggest this instead :

resp.filter((v) => v.includes("'") || v.includes("’"))