function renderShoppingList() {
  // clear all existing elements from list
  clearElement(listBody);
  // iterate through list array
  list.forEach((item) => {
    // create new list item for each array object
    const listItemElement = document.importNode(listItemTemplate.content, true);
    const checkbox = listItemElement.querySelector("input");
    checkbox.id = item.id;
    checkbox.checked = item.complete;
    const label = listItemElement.querySelector("label");
    label.htmlFor = item.id;
    const edit = listItemElement.querySelector(".sliEdit");
    edit.id = item.id;
    // conditionals to define how to render items depending on data entered
    if (item.units !== "") {
      if (item.quantity > 1) {
        if (item.units === "box") {
          label.append(
            item.name + ", " + item.quantity + " " + item.units + "es"
          );
          listBody.appendChild(listItemElement);
        } else {
          label.append(
            item.name + ", " + item.quantity + " " + item.units + "s"
          );
          listBody.appendChild(listItemElement);
        }
      } else {
        label.append(item.name + ", " + item.quantity + " " + item.units);
        listBody.appendChild(listItemElement);
      }
    } else {
      if (item.quantity > 1) {
        label.append(item.name + ", " + item.quantity);
        listBody.appendChild(listItemElement);
      } else {
        label.append(item.name);
        listBody.appendChild(listItemElement);
      }
    }

    // alternating background colors for list items
    const listItemBkgd = document.querySelectorAll(".listItem");

    listItemBkgd.forEach(function (item, index) {
      if (parseInt(index) % 2 === 0) {
        item.style.background = "#6b7a66";
        item.style.color = "white";
        item.classList.add = "listItemEven";
        item.firstElementChild.className = "sliCheckboxEven";
      }
    });
  });

  // add edit event handler
  const editItemBtn = document.querySelectorAll(".sliEdit");

  editItemBtn.forEach((e) => e.addEventListener("click", editSli));

  renderListCount();
}
// render shopping list items in body of list

render shopping list items in body of list
render shopping list items in body of list
function renderShoppingList() {
  clearElement(listBody);
  list.forEach((item) => {
    const listItemElement = document.importNode(listItemTemplate.content, true);
    const checkbox = listItemElement.querySelector("input");
    checkbox.id = item.id;
    checkbox.checked = item.complete;
    const label = listItemElement.querySelector("label");
    label.htmlFor = item.id;
    const edit = listItemElement.querySelector(".sliEdit");
    edit.id = item.id;
    if (item.units !== "") {
      if (item.quantity > 1) {
        if (item.units === "box") {
          label.append(
            item.name + ", " + item.quantity + " " + item.units + "es"
          );
          listBody.appendChild(listItemElement);
        } else {
          label.append(
            item.name + ", " + item.quantity + " " + item.units + "s"
          );
          listBody.appendChild(listItemElement);
        }
      } else {
        label.append(item.name + ", " + item.quantity + " " + item.units);
        listBody.appendChild(listItemElement);
      }
    } else {
      if (item.quantity > 1) {
        label.append(item.name + ", " + item.quantity);
        listBody.appendChild(listItemElement);
      } else {
        label.append(item.name);
        listBody.appendChild(listItemElement);
      }
    }
    const listItemBkgd = document.querySelectorAll(".listItem");
    listItemBkgd.forEach(function (item, index) {
      if (parseInt(index) % 2 === 0) {
        item.style.background = "#6b7a66";
        item.style.color = "white";
        item.classList.add = "listItemEven";
        item.firstElementChild.className = "sliCheckboxEven";
      }
    });
  });
  const editItemBtn = document.querySelectorAll(".sliEdit");
  editItemBtn.forEach((e) => e.addEventListener("click", editSli));
  renderListCount();
}
function renderShoppingList ( ) { clearElement ( listBody ) ; list . forEach ( ( item ) => { const listItemElement = document . importNode ( listItemTemplate . content , true ) ; const checkbox = listItemElement . querySelector ( "input" ) ; checkbox . id = item . id ; checkbox . checked = item . complete ; const label = listItemElement . querySelector ( "label" ) ; label . htmlFor = item . id ; const edit = listItemElement . querySelector ( ".sliEdit" ) ; edit . id = item . id ; if ( item . units !== "" ) { if ( item . quantity > 1 ) { if ( item . units === "box" ) { label . append ( item . name + ", " + item . quantity + " " + item . units + "es" ) ; listBody . appendChild ( listItemElement ) ; } else { label . append ( item . name + ", " + item . quantity + " " + item . units + "s" ) ; listBody . appendChild ( listItemElement ) ; } } else { label . append ( item . name + ", " + item . quantity + " " + item . units ) ; listBody . appendChild ( listItemElement ) ; } } else { if ( item . quantity > 1 ) { label . append ( item . name + ", " + item . quantity ) ; listBody . appendChild ( listItemElement ) ; } else { label . append ( item . name ) ; listBody . appendChild ( listItemElement ) ; } } const listItemBkgd = document . querySelectorAll ( ".listItem" ) ; listItemBkgd . forEach ( function ( item , index ) { if ( parseInt ( index ) % 2 === 0 ) { item . style . background = "#6b7a66" ; item . style . color = "white" ; item . classList . add = "listItemEven" ; item . firstElementChild . className = "sliCheckboxEven" ; } } ) ; } ) ; const editItemBtn = document . querySelectorAll ( ".sliEdit" ) ; editItemBtn . forEach ( ( e ) => e . addEventListener ( "click" , editSli ) ) ; renderListCount ( ) ; }
render shopping list items in body of list
render shopping list items in body of list
// clear all existing elements from list
 // iterate through list array
 // create new list item for each array object
 // conditionals to define how to render items depending on data entered
 // alternating background colors for list items
 // add edit event handler
