Challenge 3 — Solution Task: Write functions saveTodos(todos) and loadTodos() using the save/load pattern from this chapter, where todos is an array of strings. saveTodos should stringify and store the array; loadTodos should return the parsed array, or an empty array [] (not null) if nothing has been saved yet. Save 3 todos, then load and log them. function saveTodos(todos) { localStorage.setItem("todos", JSON.stringify(todos)); } function loadTodos() { const stored = localStorage.getItem("todos"); return stored ? JSON.parse(stored) : []; } saveTodos(["Buy milk", "Walk the dog", "Write JS notes"]); const todos = loadTodos(); console.log(todos); Expected output: ["Buy milk", "Walk the dog", "Write JS notes"] Notes: - The ternary (stored ? JSON.parse(stored) : []) means loadTodos() is always safe to call, even before saveTodos has ever run — it returns a real, usable empty array instead of null, so code like loadTodos().length never crashes. - Returning [] instead of null specifically means calling code never needs an extra null-check before treating the result as an array — array methods like forEach/map (Fundamentals Chapter 6) work immediately either way. - saveTodos and loadTodos together hide the JSON.stringify/parse and localStorage details entirely — calling code only ever deals with a plain array of strings.