Basic HTML5 localStorage example
Type a username and
password into the fields and click "Log in" to display the data in an
alert. The data is stored at this point. Then you can retrieve it by
clicking "Show Data".
To test that localStorage is working, remove the localStorage.setItem
lines in the script.js code, then fill in the fields and click "Log
in". The alert will display the inputted values but clicking the "Show Data"
button will display "null" because by removing localStorage.setItem the values are not being stored. Therefore the "Show Data" button will not have anything to show.
Basic JS with JSON example
Both examples are very basic and raw; I know there are
elements of the code which can be improved but my main goal was to gain an understanding of how JSON and localStorage works. I think I have achieved my goal and I plan to use my prototypes as a starting point for improving my JS Quiz.
I hope my examples are helpful! Feel free to fork the repos and submit pull requests with improvements!