For some reason my variable isn't being stored when leaving the scope in the if statement. Code is below. I am pretty new to javascript, so I am a little unsure if it's a small fix?
var address = document.getElementById('address').value;
var lng = '';
geocoder.geocode({'address': address}, function(results, status) {
if (status === 'OK') {
lng = ''+results[0].geometry.location.lng();
alert(lng); // prints out the lng()
}
})
alert(lng); // prints out blank