JavaScript Storage Events — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Storage Events 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
See it does not fire locally
easy10 minShow that changing storage in the same tab does not fire the event.
- 2
Read the event details
easy10 minBuild a message from a fake storage event.
- 3
React to one key
easy10 minOnly respond when the logout key changes.
- 4
Detect a full clear
easy10 minReport a full clear when the key is null.
- 5
Attach and check the listener type
medium10 minConfirm a storage listener was actually attached.
Find the bug(5)
- 1
Fix the event expected in the same tab
easy8 minThe storage event never fires in the tab making the change.
- 2
Fix the wrong key checked
easy8 minThe handler is looking at the wrong property name.
- 3
Fix the clear check using undefined
easy8 minA full clear sets key to null, not undefined.
- 4
Fix the listener attached to storage itself
easy8 minThe event is listened for on window, not on localStorage.
- 5
Fix the message built with the wrong order
easy8 minThe old value should come before the new one.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace