LESSON 29
Local Storage
Learning objective: Save data in the browser with localStorage.
Understand
localStorage keeps small data between visits.
localStorage.setItem saves a string by key and getItem reads it back — even after the page is closed and reopened. Use JSON.stringify and JSON.parse to store objects. This is exactly how Bynteq remembers your progress.
Analogy: localStorage is like a small notebook the browser keeps for your site between visits.
See It in Action
Saving and reading:
localStorage.setItem("name", "Sam");
const saved = localStorage.getItem("name");
console.log(saved); // SamHow it works: The value is stored under the key 'name' and can be read back later, even after a refresh.
Try It Yourself
- Save a value with
setItem. - Refresh and read it with
getItem. - Store an object using
JSON.stringify.
Quick Quiz
What does localStorage let you do?
Challenge
Save a user's name and greet them by it after a refresh.
Success condition: Your page remembers the name after being reloaded.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →