Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions