I have the following data:
properties: {
'2': [
{
id: "2015-1160312",
date: "2015-01-23",
number: 1,
nature: "Sell",
value: 310000,
address_number: 10,
adresse_code: "ST LINCOLN",
ZIPCODE: "CO80216",
number_rooms: 2}
],
'4': [
{
id: "2015-1160312",
date: "2015-01-23",
nature_mutation: "Sell",
value: 450000,
address_number: 15,
adresse_code: "ST HOOHER",
ZIPCODE: "CO45216",
number_rooms: 4
}
]
}
And I have a filter object, that is created dynamically:
let selectedFilters = {1,2,3};
I want to filter the properties where the "number_rooms" corresponds to the selectedFilters items. In the example, I should only get the first item
It seems properties
is already grouped by number_rooms
so that means you don't need to filter, just iterating over selectedFilters
keys will help. Something like -
Object.keys(selectedFilters).forEach(k=> {
// properties[k] if exists -> will give you required data
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.