I am trying to filter the products of an array in order to show them, if the filter works, but how can I make it return a value if it does not find a match? For now I have my filter like this:
findproduct: function() {
if (this.product === "") {
this.listFinishedproducts = this.filterFinishedproducts;
}else {
this.listFinishedproducts = this.filterFinishedproducts.filter(products => {
return products.room.match(this.product.toLowerCase())
|| products.name.match(this.product.toLowerCase())
|| products.lot.match(this.product.toLowerCase())
|| products.quantity_packed.match(this.product.toLowerCase())
|| products.pallet.match(this.product.toLowerCase());
});
}
}
If no match is found you will have an empty array, so just assign whatever value you want to this.listFinishedproducts