0

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"
      }
    ]


1

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.