Question
I am new to coding I am lost and I still don't understand what I am doing. I need help with this lesson and I
I am new to coding I am lost and I still don't understand what I am doing. I need help with this lesson and I will like a step by step explanation if possible here is the problem:
* Diego needs you to get the Cart Totals working. Complete the following: 1. Loop through all the items in the cart and add up the `price` for each item, storing the result in `subtotal`. 2. Set the `total` variable equal to the `subtotal` plus the `shipping` cost. */
let cart = [ {
itemName: "Walnut Guitar Mount",
price: 62.0, },
{ itemName: "Wooden Guitar Pick Box",
price: 8.5, },
{ itemName: "Mahogany Guitar Stand",
price: 149.99, }, ],
let subtotal = 0;
let shipping = 12.99;
let total = 0;
It keeps saying when I run my solution let is a reserved word and in red SYNTAXERROR... I dont understand what this means and this what I have as a solution:
for (let i = 0; i < cart.length; i++) { subtotal += cart[i].price; }
total = subtotal + shipping;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started