Challenge 1 — Solution Task: Using the module pattern (IIFE returning an object), build a TodoModule with private state (an array) and a public interface of addTodo(text) and getAll(). Add 3 todos and log the result of getAll(), then confirm TodoModule.todos is undefined. const TodoModule = (function () { let todos = []; return { addTodo(text) { todos.push(text); }, getAll() { return todos; } }; })(); TodoModule.addTodo("Buy milk"); TodoModule.addTodo("Walk the dog"); TodoModule.addTodo("Write JS notes"); console.log(TodoModule.getAll()); console.log(TodoModule.todos); Expected output: ["Buy milk", "Walk the dog", "Write JS notes"] undefined Notes: - The IIFE — (function () { ... })() — runs immediately the moment TodoModule is declared, and only the returned object (with addTodo and getAll) becomes TodoModule's actual value. - todos lives entirely inside the closure created by the IIFE — there is no way to reach it except through addTodo/getAll, which is exactly why TodoModule.todos is undefined. - getAll() returns the real array, not a copy — calling addTodo again later would still affect what a previously-stored reference to getAll()'s result shows, since arrays are reference types (Intermediate Chapter 6).