(function () {
const key = “santasSackItems”;
const input = document.getElementById(“sackItem”);
const addBtn = document.getElementById(“addToSack”);
const clearBtn = document.getElementById(“clearSack”);
const list = document.getElementById(“sackList”);
const countEl = document.getElementById(“sackCount”);
function load() {
try { return JSON.parse(localStorage.getItem(key) || “[]”); }
catch { return []; }
}
function save(items) {
localStorage.setItem(key, JSON.stringify(items));
}
function render() {
const items = load();
list.innerHTML = “”;
items.forEach((txt, i) => {
const li = document.createElement(“li)