Challenge 3 — Solution Task: Write a function createInventory() returning an object with addItem(name, qty), removeItem(name), and getCount(name) methods, all closing over a private object that the caller can never access directly. Add a few items, remove one, and confirm getCount reflects the changes. function createInventory() { const items = {}; return { addItem(name, qty) { items[name] = (items[name] || 0) + qty; }, removeItem(name) { delete items[name]; }, getCount(name) { return items[name] || 0; } }; } const inventory = createInventory(); inventory.addItem("apples", 10); inventory.addItem("bananas", 5); inventory.addItem("apples", 3); console.log(inventory.getCount("apples")); // 13 console.log(inventory.getCount("bananas")); // 5 inventory.removeItem("bananas"); console.log(inventory.getCount("bananas")); // 0 console.log(inventory.items); // undefined — no direct access Expected output: 13 5 0 undefined Notes: - items[name] = (items[name] || 0) + qty handles both "first time adding this item" (items[name] is undefined, so || 0 kicks in) and "adding more to an existing item" in one line. - getCount uses the same || 0 fallback so asking about a removed or never-added item returns 0 instead of undefined. - inventory.items is undefined because items only exists inside createInventory's closure — the returned object exposes three methods, never the underlying data structure itself.