Question: Use JavaScript code to interact with web pages with numeric operations, template strings, and arrays. Create a function checkout() to do the following: Ask the

  1. Use JavaScript code to interact with web pages with numeric operations, template strings, and arrays.

    Create a function checkout() to do the following:
    1. Ask the user for 2 room rates, one at a time, and add them to the roomRate array.
    2. Calculate the GST(5%, use 0.05), PST(8%, use 0.08), and the amount after taxes for each room.
    3. At the same time, it will also accumulate the total of the after tax amount for the rooms.
    4. The input room rates and the calculation result will be added to an html string which will be assigned to an element's innerHTML property.
    5. Write a JS statement to get hold of the main element of the page, then assign the html string to the element's innerHTML property.
    HINT: Pay attention to type conversion. For this assignment, any number of decimal places would be fine. To show the values with proper decimal places, consider to use toFixed() method.
  2. Add a button to the main element of the rooms page (in HTML). When it's clicked on, the checkout function will be called. HINT: Add the onclick attribute to the button in html: onclick="call the checkout function".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!