Question: let table = document.getElementById ( ' myTable ' ) ; let subTotal = 0 ; for ( let row of table.rows ) { let priceCell

let table = document.getElementById('myTable');
let subTotal =0;
for (let row of table.rows){
let priceCell = row.cells[0];
let quantityCell = row.cells[1];
let price = parseFloat(priceCell.textContent);
let quantity = parseInt(quantityCell.textContent);
let rowSubTotal = price * quantity;
priceCell.textContent = rowSubTotal.toLocaleString('en-US',{style: 'currency', currency: 'USD'});
priceCell.classList.add('price-column');
subTotal += rowSubTotal;
}
let tax = subTotal *0.12;
let total = subTotal + tax;
let subTotalElement = document.createElement('p');
subtotalElement.textContent =`Subtotal: ${subTotal.toLocaleString('en-US',{ style: 'currency', currency: 'USD' })}`;
subtotalElement.classList.add('subtotal');
let taxElement = document.createElement('p');
taxElement.textContent =`Tax: ${tax.toLocaleString('en-US',{ style: 'currency', currency: 'USD' })}`;
taxElement.classList.add('tax');
let totalElement = document.createElement('p');
totalElement.textContent =`Total: ${total.toLocaleString('en-US',{ style: 'currency', currency: 'USD' })}`;
totalElement.classList.add('total');
let tableFooter = document.getElementById('tableFooter');
tableFooter.appendChild(subtotalElement);
tableFooter.appendChild(taxElement);
tableFooter.appendChild(totalElement);
HOW DO I FIX THIS ERROR
 let table = document.getElementById('myTable'); let subTotal =0; for (let row of

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!