So I am making a chrome extension game. I have a highscore variable that I want to store with chrome.storage.
In the background.js, I have :
chrome.storage.sync.set({"highScore": 0});
and in the popup.js, I have :
document.addEventListener("DOMContentLoaded", function () {
 
    let highScore;
    
    chrome.storage.sync.get('highScore', (result) => {
        highScore = result.highScore;
        console.log(highScore); // here it is 0
    })
    console.log(highScore); // here it is undefined
});
why ?
Is there a way to do what I want to do ?
