const commandAction = document.getElementById("command-action"); const rmButton = document.getElementById("remove-command"); const locals = { command: document.querySelector("#command1>h2").innerHTML.replace(" 1", ""), sandwich: document.querySelector("label[for='sandwich1']").innerHTML, day: document.querySelector("label[for='day1']").innerHTML }; function lastCommandId() { let list = document.querySelectorAll("div.command h2"); return parseInt(list[list.length-1].innerText.replace("Command ", "")); } document.getElementById("add-command").addEventListener("click", () => { let id = lastCommandId() + 1; commandAction.insertAdjacentHTML("beforebegin", `