I've got this object:
this.contacts = [
{
name: "",
el: ["one", "two"]
},
{
name: "",
el: ["three", "four"]
}]
How to filter the above so for example only the first object is returned when I search for "two"?
My try so far:
filterItems(searchTerm) {
return this.contacts.filter((item) => {
return item.el.filter((user) => {
return user.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1;
})
});
}
It doesn't return anything of course, why?