Save a step number and read it back.
Acceptance criteria
- 1.#out should show 2.
JavaScript Tutorial · JavaScript Storage & BOM
These 10 tasks go with the JavaScript sessionStorage chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “sessionStorage behaves like localStorage but clears when the tab closes.” .
1.Save and readexercise · easy · 10 min
Save a step number and read it back.
Passes when: #out should show 2.
2.Store form progressexercise · easy · 10 min · practice plan
Save an object as JSON for a form step.
Passes when: #out should show Ada.
3.Remove a session valueexercise · easy · 10 min · practice plan
Set and then remove a key, and report it is gone.
Passes when: #out should show gone.
4.Store a count as textexercise · easy · 10 min · practice plan
Show that a stored number comes back as a string.
Passes when: #out should show string.
5.Use both storages togetherexercise · medium · 10 min · practice plan
Save one value in each and read both back.
Passes when: #out should show dark and 3.
6.Fix localStorage used for temporary databug fix · easy · 8 min
Data that should not outlive the tab belongs in sessionStorage, not localStorage.
Passes when: #out should show found it.
7.Fix the object saved without stringifybug fix · easy · 8 min · practice plan
Without JSON.stringify the object becomes useless text.
Passes when: #out should show Ada.
8.Fix the stored count added like a numberbug fix · easy · 8 min · practice plan
The stored value is text, so plus joins instead of adding.
Passes when: #out should show 10.
9.Fix the wrong storage read backbug fix · easy · 8 min · practice plan
The value was saved in one storage and read from the other.
Passes when: #out should show found it.
10.Fix removeItem given the wrong keybug fix · easy · 8 min · practice plan
The key passed to removeItem must match exactly.
Passes when: #out should show gone.
Between them these tasks cover sessionStorage, Per-tab scope and Same API.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.