Read
- FunWebDev Chapter 10.1 (Array Functions)
- Yes, you’ve seen these before! Now’s a great time to review 😉
- FunWebDev Chapter 10.4.1 (brief overview)
- The Modern JavaScript Tutorial - localStorage
Activity
For this activity, you will be trying out localStorage
for yourself! Create two html files called 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
load.html
- First, add three elements to display the saved data:
- A
div
with the id name-display
- A
div
with the id favorite-display
- A
ul
with the id quotes-display
- Then, in a script element (at the bottom of the
body
), write code to:
- Load the value with the
fullname
key from localStorage and set the first div
’s textContent
to that value
- Load the value with the
favnumber
key, add 5 to it, and then set it to the second div
- Load the value with the
quotes
key and make a new list entry for each quote
- Hint: you will need to “parse” the string and convert it back to an object
© 2011-2025 Michael S. Kirkpatrick.
This work is licensed under a
.