Skip to main content

Practice ยท 2 of 3

Storage Guard

Write loadSetting(storage, key, fallback) โ€” storage provides getItem/setItem. Parse the stored JSON safely: missing key, invalid JSON, or wrong-typed value all RETURN fallback; only a value passing isShape (provided as an argument: (v) => boolean) returns { ok: true, value }. Also write saveSetting(storage, key, value) that stores JSON.stringify(value).

Difficulty: intermediate

Back to lesson: Practice: Boundaries โ€” Practice