Testing How LocalStorage Works
Open up your Chrome DevTools.
Find the Chrome DevTools Applications tab. (Note that you might have to click on the chevron
>>. The tab is called Storage on Firefox.)
Notice all the different ways you can store things locally. We will just be using
LocalStorage then click on the local web address for your game:
|Browsersync||VSCode Live Server Extension|
Click on the Console tab to switch.
Now type the following to set the value of the
undefined just means that nothing was returned from the function.
Notice that the value is always a string.
Now click on the Application/Storage tab and look for
Go back to the Console and change the value by setting it to something else. You can use the arrow keys in the Console to go up in your command history.
Just to live dangerously let’s change the value to a number instead of a string to see what happens.
100 into a string
'100' for you.
Now let’s just get the score.
Now you’re ready to use this to store stuff for our web sites, apps, and games.