Using Google's Maps API, I want to be able to find the value of a key within an object by the value within an array within the same object. When I "Inspect Element" on my page in order to view the console, here is what it shows in terms of object structure:
results: {
address_components [
0: Object: {
long_name: "704",
short_name: "704",
types [
0:"street_number"
]
}
1: Object {...}
2: Object {...}
3: Object {...}
]
place_id:"8AS8D8F8A881C81DA6S6D8"
}
I want to be able to find "street_number" in the object so I can find the corresponding value of "704" that also resides in the object.
The tricky part is that the values within "address_compenents" are not always in the same order so I cannot just write results[0].address_components[0].long_name
in my javascript to find it. I am restricted to javascript in this project so any answers in that language would be much appreciated. Thank you in advance!
Note: I am not opposed to using libraries like lodash or underscore if it helps solve the problem.