Hello
I need to know if i understood “Variables” well
Know when i am coding, i initialize variable “Score” = 0
User will start the game and his new score in 17
now, which way i should use
Way one: App sets variable “Score”=17 and Local Storage key “Score”=17 and when user uses the app again app will call Local Storage Key and sets the variable “Score” to the local storage value.
or
Way two: when game finishes, app sets variable “Score” = 17 only
MY QUESTION:
in case of using 2nd way, when the user opens the app again, will variable value be 17 or it will be 0 and i have to call Local Storage?
You need to use local storage.
The current value of a variable is maintained as long as the app is running. Next time the app will be started, all the initialization will run anew, so the score would start from 0 again.
If you use an app variable, it will reset every time the app is closed and re-opened.
If you use a stored variable, it will be stored and recalled even if the app has been closed and re-opened.
Stored variables work just like the Local Storage component, except they are easier to work with!