Question: if ( document . readyState = = = 'loading' ) { document.addEventListener ( ' DOMContentLoaded ' , calculateCost ) } else { calculateCost ( )
ifdocumentreadyState 'loading'
document.addEventListenerDOMContentLoadedcalculateCost
else
calculateCost;
function calculateCost
const backpackPrice NumberdocumentgetElementByIdbackprice'textContent;
const calculatorPrice NumberdocumentgetElementByIdcalcprice'textContent;
const textbookPrice NumberdocumentgetElementByIdtextprice'textContent;
const taxRate ;
const subTotal calculateSubtotalbackpackPrice calculatorPrice, textbookPrice;
const salesTax calculateSalesTaxsubTotal;
const totalCost calculateTotalsubTotal salesTax;
console.logSubtotal: $ subTotal.toFixed;
console.logSales Tax: $ salesTax.toFixed;
console.logTotal Cost: $ totalCost.toFixed;
function calculateSubtotalbackpack calculator, textbook
return backpack calculator textbook;
function calculateSalesTaxsubTotal
const salesTax
return subTotal salesTax;
function calculateTotalsubTotal salesTax
return subTotal salesTax;
Use document.querySelectorAll to read the elements that have a class attribute of "price" from the DOM. You will use price" as the CSS selector to use with the querySelectorAll method to read the prices.
How do I interpret document.querySelectorAll into my code
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
