const amount = document.getElementById("amount"); function setAmount(btn) { let id = btn.getAttribute("id"); let min = amount.getAttribute("min"); let max = amount.getAttribute("max"); let step = amount.getAttribute("step"); let value = amount.getAttribute("value"); let calcStep = (id == "button_increment") ? (step * 1) : (step * -1); let newAmount = parseInt(value) + calcStep; if (newAmount >= min && newAmount <= max) { amount.setAttribute("value", newAmount); } }