Professional Documents
Culture Documents
STEPS:
For this hands on exercise, we’re going to compute for the total price of the items in the
cart.
2. Create a variable
Inside the function loadCart(), create a new variable that will store the total price of the items
in the cart.
PRINT
/
A variable is a name or identier that represents some data that you set. It can change its value
during the script.
For example
var variableName;
Note: You can initialize the value of a variable upon declaring it.
3. Compute for the total price
For every run in the LOOP, add the prices of the item to variabletotal to get the total price of
the item. Price per item equates to the price of the items times the quantity.
PRINT
/
Also, you must store the total price temporarily into the session storage. You can add it after
the code computing for the nal price.
PRINT
/
Now try to see if your codes are working properly by adding two different items in the cart. Go
to cart page afterwards. The page should have displayed the correct total price.
PRINT
/
EVALUATE
OBJECTIVE TEST: