Question: if ( document . readyState = = = 'loading' ) { document.addEventListener ( ' DOMContentLoaded ' , showItems ) ; } else { showItems (
ifdocumentreadyState 'loading'
document.addEventListenerDOMContentLoaded showItems;
else
showItems;
function showItems
const backPrice document.getElementsByClassNameprice;
const calcPrice document.getElementsByClassNameprice;
const textPrice document.getElementsByClassNameprice;
const backpackPrice backPrice.textContent;
const calculatorPrice calcPrice.textContent;
const textbookPrice textPrice.textContent;
const prices NumberbackPackPriceNumbercalculatorPriceNumbertextPrice;
return prices;
function pricesAddprices
let sum ;
for let i ; i prices.length; i
sum Numberpricesi;
return sum;
function calcSum
const prices showItems;
const subTotal pricesAddprices;
return subTotal;
function taxRate
const taxRate ;
return taxRate;
function calcTaxsum
let taxAmount ;
const rate taxRate;
taxAmount sum rate;
return taxAmount;
function calcFinalCostsum tax
const finalCostAmount sum tax;
document.getElementByIdsubtotal"textContent sum.toFixed;
document.getElementByIdtaxamount"textContent tax.toFixed;
document.getElementByIdtotaltextContent finalCostAmount.toFixed;
function
const sum calcSum;
const tax calcTaxsum;
calcFinalCostsum tax;
;
Can you fix code with proper way of using getElementbyClassName
Also correct what needs to be corrected to not bring up errors
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
