How can I filter Objects based on value from another array the object is as follows:
const myJson = {
"2020-01-10": [
{
"id": 1,
"region": "MH",
"category": "demo",
"country": "India",
"descp": "due date for filing GSTR-7",
"applicableto": "",
"duedate": "2020-01-10",
"previousdate": null
},
{
"id": 2,
"region": "MH2",
"category": "demo",
"country": "India2",
"descp": "due date for filing GSTR-7",
"applicableto": "",
"duedate": "2020-01-10",
"previousdate": null
}
],
"2020-01-28": [
{
"id": 3,
"region": "GJ",
"category": "test",
"country": "India",
"descp": "GSTR-11 Return for details of goods and services purchased in India",
"applicableto": "",
"duedate": "2020-01-28",
"previousdate": null
},
{
"id": 3,
"region": "MH",
"category": "test",
"country": "India",
"descp": "GSTR-11 Return for details of goods and services purchased in India",
"applicableto": "",
"duedate": "2020-01-28",
"previousdate": null
}
]
}
and my region array consists of
regionArr=['MH','MH2'].
I want to filter the above object by checking the whether the regionArr elements are mentioned in any of the object for the key region using lodash. I tried
._every(this.regionArr, el =>
._includes(event.region, el)
);
but it's not working. I'm expecting an output like this
const myJson = {
"2020-01-10": [
{
"id": 1,
"region": "MH",
"category": "demo",
"country": "India",
"descp": "due date for filing GSTR-7",
"applicableto": "",
"duedate": "2020-01-10",
"previousdate": null
},
{
"id": 2,
"region": "MH2",
"category": "demo",
"country": "India2",
"descp": "due date for filing GSTR-7",
"applicableto": "",
"duedate": "2020-01-10",
"previousdate": null
}
],
"2020-01-28": [
{
"id": 3,
"region": "MH",
"category": "test",
"country": "India",
"descp": "GSTR-11 Return for details of goods and services purchased in India",
"applicableto": "",
"duedate": "2020-01-28",
"previousdate": null
}
]
}