Advanced
Settings guarded by a Proxy
Write createSettings() that returns a Proxy around { volume: 50, theme: "light" } with these rules for writes:
volume must be a whole number from 0 to 100, otherwise throw a RangeError. theme must be "light" or "dark", otherwise throw a TypeError. Writing any other property throws a TypeError, and nothing is stored when a write is rejected.
Show the starting settings in #status as Volume 50, theme light.
What Check tests
createSettings()starts with volume 50 and theme light- Valid writes are stored
- Bad volumes throw a RangeError and aren't stored
- A bad theme throws a TypeError
- Unknown properties are rejected
- Uses a Proxy
- The page shows
Volume 50, theme light
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.