Ask Question
1 January, 10:57

Jasmine is writing a shopping app. She has created a variable to keep track of the number of items in the shopping cart. Every time someone clicks the "addItemButton", she would like the variable to increase by 1.

What code should Jasmine insert where it says in order for her app to work? a) cart total = 1;

b) cartTotal + 1;

c) cartTotal = cartTotal + 1;

d) var cartTotal = cartTotal + 1;

+3
Answers (1)
  1. 1 January, 11:27
    0
    C. carTotal=carTotal + 1;

    Explanation:

    Option 'c' is the correct answer, because when some click on the "additembutton" the variable cartTotal should increment by 1. As jasmine want to track the record of no. of items in cart, each time customer will click "additembutton" the variable "cartTotal" increment by 1 and also update the value of that variable. e. g

    If initially

    cartTotal=0

    When 1st time additembutton pressed

    CartTotal = CartTotal + 1 = => will make it as CartTotal=0+1 = => CartTotal = 1

    Now CartTotal=1;

    When customer 2nd time press "additembutton"

    CartTotal = CartTotal + 1 = => will make it as CartTotal=1+1 = => CartTotal = 2

    This process will continue and update the cartTotal till the customer add items into the cart.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Jasmine is writing a shopping app. She has created a variable to keep track of the number of items in the shopping cart. Every time someone ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers