function getPostalCode(place) { for(var i=0; i < place.address_components.length; i++) { var component = place.address_components[i]; if(component.types[0] == "postal_code") { return component.long_name; } } }