Javascript function to store data locally is not working when deployed, other functions no problem

I am using the browser’s local storage to store HighScore value. After the project is deployed, the value is now NAN instead of a number. I tried modifying the function and add !isNAN, problem persists.

Is there a workaround for it to still work?

Domain: no custom domain

Git Repo:

Thank you!

There’s a problem on your code. If you’d remove the localstorage entries on your localhost, you’d run across the same issue.

const oldHighScore = parseInt(localStorage.getItem('highScore'), 10);

What if there’s no localstorage entry highScore? You’d be running a parseInt on null (NaN).

Hey Tom, good point! I totally miss that, newb mistake :slight_smile:
Thank you!

It happens to the best of us! Glad it’s working now