How do i filter the data based on the id? Example if i wanted to filter id= "24". So it will filter out the object that is matching.
[
{
"id": "Sheet1",
"data": [
{
"id": "24",
"title": "Title of article",
"date_time": "11/05/2022",
"description": "Description of Article"
},
{
"id": "25",
"title": "Title of article 2",
"date_time": "15/05/2022",
"description": "Description of Article 2"
}
]
}
]
Output:
"data": [
{
"id": "24",
"title": "Title of article",
"date_time": "11/05/2022",
"description": "Description of Article"
}
]
CodePudding user response:
I try this and i got the same output :
let arr = arrays.filter(array => array.id === "Sheet1");
let data = arr[0].data;
let result = data.filter(obj => obj.id === "24")
console.log(result)