JavaScript sessionStorage — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript sessionStorage lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Save and read
easy10 minSave a step number and read it back.
- 2
Store form progress
easy10 minSave an object as JSON for a form step.
- 3
Remove a session value
easy10 minSet and then remove a key, and report it is gone.
- 4
Store a count as text
easy10 minShow that a stored number comes back as a string.
- 5
Use both storages together
medium10 minSave one value in each and read both back.
Find the bug(5)
- 1
Fix localStorage used for temporary data
easy8 minData that should not outlive the tab belongs in sessionStorage, not localStorage.
- 2
Fix the object saved without stringify
easy8 minWithout JSON.stringify the object becomes useless text.
- 3
Fix the stored count added like a number
easy8 minThe stored value is text, so plus joins instead of adding.
- 4
Fix the wrong storage read back
easy8 minThe value was saved in one storage and read from the other.
- 5
Fix removeItem given the wrong key
easy8 minThe key passed to removeItem must match exactly.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace