title: Stuck with Javascript! - How do I use an If statement to update an element and an array?
body: <p>I am trying to build a shopping cart function for a project.</p>
  
  <p>This is what I am being asked to do:</p>
  
  <p>Inside the if statement, update the <code>orderTotal</code> element to display Total: $ and the sum of all the prices inside the <code>cartItems</code> array.</p>
  
  <p>1) Under the IF statement I am then entering: <code>orderTotal.innerHTML = "Total: $"</code>
  2) At this point I get stuck as I do not know how to add the sum of all prices in the array?</p>
  
  <p>Please help!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var cartItems = [];
  var isTotalHidden = true;
  
  var backpack = {
   name: "Backpack",
   price: 400
  }
  
  var camera = {
   name: "Camera",
   price: 300
  }
  
  function addToCart(item) {
   cartItems.push(item);
   document.getElementById("itemCounter").innerHTML = cartItems.length;
   showTotal();
  }
  
  function clickCart() {
   isTotalHidden = !isTotalHidden;
   showTotal();
  }
  
  function showTotal() {
   var orderTotal = document.getElementById("orderTotal");
   orderTotal.innerHTML = "";
   
   if (isTotalHidden === false) {
    
   }
  }</code></pre>
  </div>
  </div>
  </p>