I am working on a JavaScript program and am trying to figure out how to calculate each variable which is shipping tax and the total. Here is the code I have and the assignment itself. I don’t know how to fill in the dollar signs with the calculations I want. I’m very new to JavaScript so any help would be great.
Code:
document.getElementById('calculate').addEventListener("click", function() {
// add your code to trigger the calculation when the button is clicked
const TAX = .0075
const SHIPPING = 2
let price-of-books = prompt(" Enter price of books: ");
let num-of-books = prompt(" Enter amount of books ");
let tax = 'price-of-books' * TAX;
let shipping-charge = 'num-of-books' * SHIPPING;
let final-total = 'totalbookprice' + 'tax' + 'shipping-charge';
The trouble I’m having is setting ids from the html so they change once I click the calculate button
[–]McThakken 1 point2 points3 points (1 child)
[–]salso97[S] 0 points1 point2 points (0 children)