javascript function not correctly returning an object
<p>I'm out of ideas.  I have a javascript function that returns an object, however the console keeps complaining about an Uncaught TypeError: cannot read properly 'lat' of undefined....  From console dumping i can see that everything is passing into the function correctly and i can see that the function is working properly.  The problem is with the return.  I'm not sure whats the problem, this seems fairly straight forward.  Side note, i'm working with the google maps/geocode api.</p>

<pre><code>    function locate(val) {
        console.log(val);
        geocoder = new google.maps.Geocoder;
        geocoder.geocode({'address': val}, function(results, status) {
            if (status == 'OK') {
                var lat = results[0].geometry.location.lat();
                var lng = results[0].geometry.location.lng();
                var pos = {
                    lat: lat,
                    lng: lng
                };
                console.log('lat: ' + pos.lat);
                console.log('lng: ' + pos.lng);
                return pos;
            }
            else {
                alert('Geocode was not successful for the following reason: ' + status);
                return null;
            }
        });
    }

    for (i = 0; i &lt; address.length; i++) {
        var coord = locate(address[i].toString());
        var lat = coord.lat;
        var lng = coord.lng
        console.log(lat);
    }
</code></pre>