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