Practice ยท 1 of 2
Save and Load Settings
Write saveSettings(settings) that stores the object under key "settings" as JSON, and loadSettings() that reads it back and returns the object (default { theme: "light" } when nothing is stored). Save { theme: "dark", fontSize: 16 }, then log the loaded theme (should be dark).
Rules:
- storage is provided (same API as localStorage).
- JSON.stringify on the way in, JSON.parse on the way out.
Difficulty: beginner
Press Submit to check your solution.
Back to lesson: Practice: State That Survives