I have a array with different strings (user queries) like ['..','..'..].
I also have an array with objects [{..},{..}..]
I want to filter out and based on all objects key values that match ANY of the items/strings in the array. Does not have to match all strings in the array but just one of them In the example here: filtering an array of objects based on another array in javascript However, it filters out based on a specific key.
For example, we have two objects:
[{
message: "Hi",
unit: "Office"
},
{
message: "Bye",
unit: "Shop"
}]
With the string array/filter conditions:
['hi','school']
Would return the first object containing the "hi".
Example of code that filters out based on one key:
this.filteredCampaigns = this.convertedCampaigns.filter((key) => {
filterConditions.toLowerCase().
includes(key.description!.toString().toLowerCase())
});
Which works, but only for one key.
How to do this?