How to save the high score of a game to local storage

Hi everyone, I made a retro snake game and I’m trying to save the high score of the game after it finishes. I tried saving it to local storage in my start game function so after the game refreshes it will save the high score but it only logs the entire global object that I have thus not saving the high score after it refreshes. Here is the link to my Codepen, the code is on lines 96-103 on my javaScript file. https://codepen.io/paolo3098/pen/OJpBjLY

It appears that you are only interacting with localStorage after the game is finished. Whenever you start a new game you’ll need to check local storage for a saved game and load that data.

Yes, he save only when the isGameOver() function is called. He needs to do something like if(localStorage.getItem(‘gameLogic’) !== undefined) { load the variable values otherwise set as 0, empty object or whatever } at the beginning of the script, with the initialization of the script.