title: JavaScript getting variable from one function to another
body: <p>I am having issues passing two coordinates from one function to another. I don't really know JavaScript, but it seems to be somewhat correct. Could you please let me know where is my error?</p>
  
  <pre><code>        &lt;script type="text/javascript"&gt; 
  
          function initialize() {
              var address = "Chicago IL";
              locs= getLatLong(address);
  
              alert(locs.lat()); //does not work
              var myOptions = {
                  zoom: 4,
                  center: new google.maps.LatLng(41, -87),
                  mapTypeId: google.maps.MapTypeId.ROADMAP          
              };
  
              var map = new google.maps.Map(document.getElementById('map_canvas'),
              myOptions); 
          }
  
          function getLatLong(address){
              var geo = new google.maps.Geocoder;
              geo.geocode({'address':address},function(results, status){
                  if (status == google.maps.GeocoderStatus.OK) {
  
                      locations[0] = results[0].geometry.location.lat(); 
                      locations[1] = results[0].geometry.location.lng();                  
  
                      //alert(locations[0]); //test is good- works! Need to pass it back to function
                      //alert(locations[1]); //test is good- works! Need to pass it back to function
                      locs =results[0].geometry.location; 
                      return locs;                
                  } else {
                      alert("Geocode was not successful for the following reason: " + status);
                  }
              });
          }
      &lt;/script&gt;
  </code></pre>