Answer the question
In order to leave comments, you need to log in
Finding a value in an array of objects using underscore?
Hello. Something I can not understand how to look for values inside an array with objects, if the object also contains an array.
The structure is like this:
[{
id: 0,
regions: [
"region1",
"region2"
]
},
{
id: 1,
regions: [
"region3",
"region2"
],
{
id: 2,
regions: [
"region1"
]
}
}
]
Answer the question
In order to leave comments, you need to log in
arr.filter((elem) => elem.regions.includes('region1'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question