Could someone explain to me why the value of the variable user coordinates is a void value. I’ve based my code off of the solution of this:How to return the response from an asynchronous call
Any help would be appreciated.
function getLocation(callback) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
var uCoords = [lat, long];
return callback(uCoords)
});
}
}
var userCoordinates= getLocation(function(position) {
console.log(position)
return position;
})