Prep 10: Save and Load
Due: Wednesday, Apr 16th
Read¶
- 5.5 Table and Form Accessibility
- 5.6 Styling and Designing Forms
- 10.4 Using Browser APIs
- LocalStorage, sessionStorage – from the Modern JavaScript Tutorial
Write¶
Try out localStorage for yourself!
Create two html files named save.html and load.html.
You may download this template file to help you get started.
save.html¶
- In a script element, write code to:
- Save your full name to a localStorage entry with the key
fullname - Save your favorite number to an entry with the key
favnumber - Save an array of at least three quotes to an entry with the key
quotes- Hint: you will need to "stringify" the object
- Save your full name to a localStorage entry with the key
load.html¶
- First, add three elements to display the saved data:
- A
divwith the idname-display - A
divwith the idfavorite-display - A
ulwith the idquotes-display
- A
- Then, in a script element (at the bottom of the
body), write code to:- Load the value with the
fullnamekey from localStorage and set the firstdiv'stextContentto that value - Load the value with the
favnumberkey, add 5 to it, and then set it to the seconddiv- Hint: the value will be loaded as a string, so you will need to convert it to an int.
- Load the value with the
quoteskey and make a new list entry for each quote- Hint: you will need to "parse" the string and convert it back to an object
- Load the value with the
Submission¶
When you are finished, submit both files to Gradescope.