js/catalog.js
// TODO: As you add items into the cart, show them (item & quantity) in the cart preview div
As you add items into the cart, show them (item & quantity) in the cart preview div
As you add items into the cart show them ( item & quantity ) in the cart preview div
function updateCartPreview() {
  var preview = document.getElementById('cartContents');
  preview.innerHTML = '';
  for (var i in cart.items ){
    var previewFig = document.createElement('figure');
    var previewItem = document.createElement('h3');
    previewItem.textContent = `${cart.items[i].product} ${cart.items[i].quantity}`;
    var productImg = document.createElement('img');
    for (var j in Product.allProducts){
      if (Product.allProducts[j].name === cart.items[i].product){
        productImg.src = Product.allProducts[j].filePath;
      }
    }
    preview.append(previewFig);
    previewFig.appendChild(previewItem);
    previewFig.appendChild(productImg);
  }
}
function updateCartPreview ( ) { var preview = document . getElementById ( 'cartContents' ) ; preview . innerHTML = '' ; for ( var i in cart . items ) { var previewFig = document . createElement ( 'figure' ) ; var previewItem = document . createElement ( 'h3' ) ; previewItem . textContent = ` ${ cart . items [ i ] . product } ${ cart . items [ i ] . quantity } ` ; var productImg = document . createElement ( 'img' ) ; for ( var j in Product . allProducts ) { if ( Product . allProducts [ j ] . name === cart . items [ i ] . product ) { productImg . src = Product . allProducts [ j ] . filePath ; } } preview . append ( previewFig ) ; previewFig . appendChild ( previewItem ) ; previewFig . appendChild ( productImg ) ; } }
TODO: As you add items into the cart, show them (item & quantity) in the cart preview div
TODO : As you add items into the cart show them ( item & quantity ) in the cart preview div
// TODO: Get the item and quantity from the form // TODO: Add a new element to the cartContents div with that information