In my array, I have objects with IDs and names. For example:
{
[
{
"id": 1,
"name": "this is book",
},
{
"id": 2,
"name": "this is a test book",
},
{
"id": 3,
"name": "this is a desk",
}
]
}
Now, let's say I want to filter and return an array that contains the word book
I attempted the following but was unsuccessful -
let test = this.pro.filter((s: { name: any; })=>s.name===book);
I also tried this but it only returned the first matching result
instead of all matching results
-
let test = this.pro.filter((s: { name: any; })=>s.name==="this is book");
Can anyone provide a solution that returns an array with all items that meet the filter condition/s?