js/scripts.js
/** 
 * Renders the Product on the screen. Does not persist to any database.
 * @param {product} product - Product object to render
 */
Renders the Product on the screen. Does not persist to any database.
@param {product} product - Product object to render
Renders the Product on the screen . Does not persist to any database . @param { product } product - Product object to render
function renderProduct(product) {
  const list = document.querySelector('.js-product-list');
  const item = document.querySelector(`[data-key='${product.id}']`);
  if (product.deleted) {
    item.remove();
    return
  }
  const node = document.createElement("li");
  node.setAttribute('class', `product-item`);
  node.setAttribute('data-key', product.id);
  node.innerHTML = `
  	-<span>${product.text}</span>
    <button class="fas fa-minus-circle delete-product js-delete-product">
    </button>
  `;
  if (item) {
    list.replaceChild(node, item);
  } else {
    list.append(node);
  }
}
function renderProduct ( product ) { const list = document . querySelector ( '.js-product-list' ) ; const item = document . querySelector ( ` ${ product . id } ` ) ; if ( product . deleted ) { item . remove ( ) ; return } const node = document . createElement ( "li" ) ; node . setAttribute ( 'class' , ` ` ) ; node . setAttribute ( 'data-key' , product . id ) ; node . innerHTML = ` ${ product . text } ` ; if ( item ) { list . replaceChild ( node , item ) ; } else { list . append ( node ) ; } }
Renders the Product on the screen.
Renders the Product on the screen .