Измените свой код следующим образом:
// add 5 other toppings here
if (document.getElementById("pepperoni").checked) total = total + 2.25;
if (document.getElementById("sausage").checked) total = total + 2.25;
if (document.getElementById("supreme").checked) total = total + 2.75;
if (document.getElementById("chicken").checked) total = total + 2.25;
if (document.getElementById("hawaiian").checked) {total = total + 2.50; }
line 66 // add 11.25% sales tax to the cost of the food (but not delivery)
total = total + (total * (11.25 / 100));
// add the delivery charge
total = total + 3.00;
// write the result to output
document.getElementById("output").innerHTML = `Your total is:
$${total.toFixed(2)`;
НЕ оборачивайте все в {}
Также учтите это вместо:
const calcToppings = () => Array.from(document.querySelectorAll('.topping'))
.filter(el => el.checked)
.map(({ value }) => parseFloat(value))
.reduce((a,v) => a+v,0);
document.addEventListener('click', ({ target }) => {
if(target.matches('button')) {
document.querySelector('.result').innerText = calcToppings();
}
});
<input type="checkbox" id="extracheese" class="topping" value="2.00"> Extra Cheese (add $2.00)
<br>
<input type="checkbox" id="pepperoni" class="topping" value="2.25"> Pepperoni (add $2.25)
<br>
<input type="checkbox" id="sausage" class="topping" value="2.25"> Sausage (add $2.25)
<br>
<input type="checkbox" id="supreme" class="topping" value="2.75"> Supreme (add $2.75)
<br>
<input type="checkbox" id="chicken" class="topping" value="2.25"> Chicken (add $2.25)
<br>
<input type="checkbox" id="hawaiian" class="topping" value="2.50"> Hawaiian (add $2.50)
<br>
<button>Click Me</button>
<div class="result"></div>
Это позволяет очень просто использовать добавлять / удалять параметры топинга без необходимости настраивать наш скрипт.