title: javascript function is returning undefined
body: <p>I'm trying to implement google maps and the problem I am having is that when I call the function getLatLng, it is returning an undefined value and I can't figure out why.</p>
  
  <pre><code>    initialize();
  
      var map;
      var geocoder;   
  
      function initialize() {
  
          geocoder = new google.maps.Geocoder();
          var address = "Rochester, MN";
          var myLatLng = getLatLng(address);
          console.log("myLatLng = "+myLatLng);
  
      }
  
      function getLatLng(address) {
  
          var codedAddress;
  
          geocoder.geocode({'address': address}, function(results, status) {
  
              if(status == google.maps.GeocoderStatus.OK) {
                  codedAddress = results[0].geometry.location;
                  console.log("codedAddress 1 = "+codedAddress);
              } else {
                  alert("There was a problem with the map");
              }
              console.log("codedAddress 2 = "+codedAddress);
          });
  
          console.log("codedAddress 3 = "+codedAddress);
          return codedAddress;
      }
  </code></pre>
  
  <p>In the firebug console, here is the output that I get in this exact order:</p>
  
  <pre><code>codedAddress 3 = undefined
  myLatLng = undefined
  codedAddress 1 = (44.0216306, -92.46989919999999)
  codedAddress 2 = (44.0216306, -92.46989919999999)
  </code></pre>
  
  <p>Why is codedAddress 3 and myLatLng showing up first in the console?</p>