Question: Hi. Wondering if you can help with a For Loop I'm making. Directions: For Loop Create a for loop that loops through the entries in

Hi. Wondering if you can help with a For Loop I'm making.

Directions:

For Loop

Create a for loop that loops through the entries in the item array. Each time through the loop, execute the commands described in the following steps:

Add the following HTML code to the value of the cartHTMLvariable

   

where item is the current value from the item array.

Add the following HTML code to the cartHTML variable to display the description, price, and quantity ordered of the item

 description  $ price   quantity  

where description is the current value from the itemDescriptionarray, price is the current value from the itemPrice array preceded by the $, and quantity is the current value from the itemQtyarray.

Declare a variable named itemCost equal to the price value multiplied by the quantity value for the current item.

Add the following HTML code to the cartHTML variable to display the cost for the item(s) ordered, completing the table row

$ cost 

where cost is the value of the itemCost variable, preceded by a $.

Add the value of the itemCostvariable to the orderTotalvariable to keep a running total of the total cost of the customer order.

For Loop Completion

After the for loop has completed, add the following HTML code to the value of the cartHTML variable, completing the shopping cart table

 Subtotal $ total    

where total is the value of the orderTotal variable, preceded by a $.

What I have so far:

var orderTotal = 0;

var cartHTML = ("

");

ItemDescriptionPriceQtyTotal

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!