P3.10: Client Local & Session Storage

LocalStorage allows web apps to save key-value strings directly inside the user's browser, persisting data even when the page is closed.


1. Set and Get Items

  • localStorage.setItem("key", "value")
  • localStorage.getItem("key")

🎓 Practice Assignment Tasks

  • Store a user's theme preference (e.g. `dark`) in localStorage.
  • Write a script that checks this value on load and toggles the body class accordingly.
Stuck? Hints available
// Write your JavaScript logic here
// Click 'Run Code' to see console outputs below
🔒 Code requirements not met yet. Complete the tasks above.
🔒 Complete the Practice Assignment above to unlock completion.
Advertisement
NS
Ask Nextsem
AI Mode
NS
Home
Course
Playground