Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started