How do I save a global variable to another layout? Specifically after the player is dead, the game goes to the final score layout and once you hit the restart button it goes back to the game layout but the global variable is not saved.
They are global and keep the same value when you go between layouts
Develop games in your browser. Powerful, performant & highly capable.
the initial variable value for the game layout is set to 0. when the layout restarts the value is NaN. should I use the localstorage to preserve its value?
There's not enough info here really. Are you setting the value yourself? NaN means it's of the wrong type.