Skip to content
Advertisement

get a deeper element which satisfies the condition

JavaScript

Need to get the postal_code value, which is the value of long_name with types=postal_code. In the api result,it seems types itself is an array. Looping and finding out is a bad method. also array_search also don’t work. Can anybody help me.

Advertisement

Answer

Just loop through the array and find an item with the postal code:

JavaScript

I’ll leave error handling to you.

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