assets/js/cart.js
// TODO: Fill in the <tr>'s under the <tbody> for each item in the cart
Fill in the 's under the  for each item in the cart
Fill in the ' s under the for each item in the cart
function showCart() {
  var tableBody = document.querySelector('#cart tbody');
  for (var i in cart.items) {
    var tr = document.createElement('tr');
     var imgTD=document.createElement('td');
    var img =document.createElement('img');
    img.setAttribute('src',cart.items[i].img);
    imgTD.appendChild(img);
    var xTD = document.createElement('td');
    var button = document.createElement('button');
    button.innerText = 'Remove';
    button.className=' remover btn btn-default btn-red btn-sm';
    button.id = i;
    xTD.appendChild(button);
    var pTD = document.createElement('td');
    pTD.textContent ="$"+ cart.items[i].price;
    var tTD = document.createElement('td');
    tTD.textContent = '$' + cart.items[i].price*cart.items[i].quantity;
    totalPrice += cart.items[i].price*cart.items[i].quantity;
    var qTD = document.createElement('td');
    qTD.textContent = cart.items[i].quantity;
    var nTD = document.createElement('td');
    nTD.textContent = cart.items[i].product;
    tableBody.appendChild(tr);
    tr.appendChild(imgTD);
    tr.appendChild(nTD);
    tr.appendChild(pTD);
    tr.appendChild(qTD);
    tr.appendChild(xTD);
    tr.appendChild(tTD);
  }
  document.getElementById('Total').innerHTML= '$' + totalPrice;
  totalPrice=0;
}
function showCart ( ) { var tableBody = document . querySelector ( '#cart tbody' ) ; for ( var i in cart . items ) { var tr = document . createElement ( 'tr' ) ; var imgTD = document . createElement ( 'td' ) ; var img = document . createElement ( 'img' ) ; img . setAttribute ( 'src' , cart . items [ i ] . img ) ; imgTD . appendChild ( img ) ; var xTD = document . createElement ( 'td' ) ; var button = document . createElement ( 'button' ) ; button . innerText = 'Remove' ; button . className = ' remover btn btn-default btn-red btn-sm' ; button . id = i ; xTD . appendChild ( button ) ; var pTD = document . createElement ( 'td' ) ; pTD . textContent = "$" + cart . items [ i ] . price ; var tTD = document . createElement ( 'td' ) ; tTD . textContent = '$' + cart . items [ i ] . price * cart . items [ i ] . quantity ; totalPrice += cart . items [ i ] . price * cart . items [ i ] . quantity ; var qTD = document . createElement ( 'td' ) ; qTD . textContent = cart . items [ i ] . quantity ; var nTD = document . createElement ( 'td' ) ; nTD . textContent = cart . items [ i ] . product ; tableBody . appendChild ( tr ) ; tr . appendChild ( imgTD ) ; tr . appendChild ( nTD ) ; tr . appendChild ( pTD ) ; tr . appendChild ( qTD ) ; tr . appendChild ( xTD ) ; tr . appendChild ( tTD ) ; } document . getElementById ( 'Total' ) . innerHTML = '$' + totalPrice ; totalPrice = 0 ; }
TODO: Fill in the <tr>'s under the <tbody> for each item in the cart
TODO : Fill in the <tr > ' s under the <tbody > for each item in the cart
// TODO: Find the table body // TODO: Iterate over the items in the cart // TODO: Create a TR // TODO: Create a TD for the delete link, quantity,  and the item // TODO: Add the TR to the TBODY and each of the TD's to the TR // xTD.innerHTML = '<Button type="button" id="remove">Remove</Button>'; //button.classList.add('remover');