I have this code and problem is that it alerts "undefined". How can I make alert (add); wait for geocoder? (I don't want to use alert (add); in function codeAdd)
        
    
    
     
    
    
<script>
function codeAdd(address){
var geocoder = new google.maps.Geocoder();
var address = "new york";
geocoder.geocode( { 'address': address}, function(results, status) {
  if (status == google.maps.GeocoderStatus.OK) {
    var latitude = results[0].geometry.location.lat();
    var longitude = results[0].geometry.location.lng();
    return latitude;
  } 
}); }
var add = codeAdd("new york");
alert (add);
</script>
</body>
</html>
 
     
    