I would like to filter array on some condition using "filter" method. If only one condition is active there is no problem. But if object in array must be under two condition there is a problem.
getFilteredItems() {
let customText = this.filters.customTextFilter.trim();
return this.filteredItems.filter((x) => {
if (customText !== '') {
return x.name.includes(customText) || x.code.includes(customText) || x.city.includes(customText);
}
if (this.filters.currencySelected !== '') {
return x.currency === this.filters.currencySelected;
}
return true;
})
}
How to join both condition if both are selected? I have another 3 conditions to join. So if some one select two condition how to check both in object and return true if both are true?
Thank you
if (condition1 && condition2)