Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting object data with key value in JavaScript

I have an object like this:

{
  "idMeal": "52795",
  "strMeal": "Chicken Handi",
  "strDrinkAlternate": null,
  "strCategory": "Chicken",
  "strArea": "Indian"
}

I am trying to get the value of other items(i.e. strMeal and strCategory) using the value of "idMeal". How can I do that?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

As far as i understood you want to filter an list of food objects, just put them in an array and filter like this:

[obj1, obj2, obj3].filter(o => o.idMeal="52795")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading