JSFiddle - React, Tailwind, and code Playground

by Russ Bain

JavaScript

var foo = null;

function getPosition() {
    // Simple wrapper
    return new Promise((res, rej) => {
        navigator.geolocation.getCurrentPosition(res, rej);
    });
}

function main() {
	getPosition().then(function(result){
  console.log('Inside the promise',  result)
  foo = result;
  }); // how to get foo to equal result?
}

main();
console.log('OUTside the promise', foo)