im struggling to understand why i cant access the properties that are created and returned in my function. if i console log the object itself. its successful, however, if i console log object.prop i get undefined. Here is my code
function geocodeAddress(value) {
let geocoder = new google.maps.Geocoder(); // eslint-disable-line
let data = {};
geocoder.geocode({'address': value}, function(results, status) {
if (status === 'OK') {
data.longitude = results[0].geometry.location.lng();
data.latitude = results[0].geometry.location.lat();
}
});
return data;
}
const place = geocodeAddress('Leeds');
console.log(place.longitude,place.latitude);