Skip to content
Advertisement

Extract value from the array of objects

I have an array of objects in a variable and I have id of the provider in a different variable. How do I get the name of the provider based on the id. how do I get the name based on the id. when I compare the id variable with with variable containing the array of objects.

Array of objects:

JavaScript

What i have tried so far.

JavaScript

Advertisement

Answer

You can use find function.

JavaScript

Or you can get it with lodash library.

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