I have a JSON file with objects like this:
[
{
"name" : "something",
"brand": "x",
"category" : "cars"
},
{
"name" : "something2",
"brand": ["x", "y"],
"category" : "bikes",
}
]
To filter by category
I do this:
filterObjects(key, value) {
if (key == 'category') {
objects.filter(item => item.category == value);
}
}
But when I try to do this with brand
, it only returns the first one.
How can I do to make my filter loop over each value and return both items?