I am not sure why I am getting undefined
in my console. I read about scope variables and learn that defining a variable outside of a scope should make that variable accessible outside of a particular function scope.
Not sure what I am doing wrong here:
const history = createHistory();
const location = history.location;
let loc;
const listen = history.listen((location) => {
loc = `${location.search}${location.hash}`;
return loc;
})
console.log(loc);
My console is logging undefined