I am attempting to access color options from a chrome extension, when I run this code, the second output is undefined, even though the variable is supposed to be able to be accessed by every part of the code because I defined it in the beginning.
var color;
function updateColor(){
chrome.storage.sync.get("favoriteColor", function(result) {
color = result.favoriteColor;
console.log(color);
});
console.log(color);
};
updateColor();
I have searched all over the internet and I am unable to come up with a solution, any help would be greatly appreciated :)