Skip to content
Advertisement

How do i access a property on the objects in an array and compare it?

So, I have a array with multiple objects with multiple properties:

JavaScript

Now I want to see if the property of one of the objects in my array matches a variable. But I dont know how to do that! I want to check if the value of property “id” in one of my objects matches my variable. Something like this:

JavaScript

but this for each object in my array

Advertisement

Answer

Try like this

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement