function handleClick(event) {
  votes--;
  let imgClicked = event.target.alt;

  for (let i = 0; i < products.length; i++) {
    if (imgClicked === products[i].name) {
      products[i].clicks++;
    }
  }
  renderImages();

  if (votes === 0) {
    myContainer.removeEventListener('click', handleClick);
    renderChart();

    // LOCAL STORAGE BEGINS
    // step 1 get data ready to store
    let stringifiedProducts = JSON.stringify(products);
    // step 2 set in local storage
    localStorage.setItem('products', stringifiedProducts);
  }

}
// initial image call to populate page
initial image call to populate page
initial image call to populate page
function handleClick(event) {
  votes--;
  let imgClicked = event.target.alt;
  for (let i = 0; i < products.length; i++) {
    if (imgClicked === products[i].name) {
      products[i].clicks++;
    }
  }
  renderImages();
  if (votes === 0) {
    myContainer.removeEventListener('click', handleClick);
    renderChart();
    let stringifiedProducts = JSON.stringify(products);
    localStorage.setItem('products', stringifiedProducts);
  }
}
function handleClick ( event ) { votes -- ; let imgClicked = event . target . alt ; for ( let i = 0 ; i < products . length ; i ++ ) { if ( imgClicked === products [ i ] . name ) { products [ i ] . clicks ++ ; } } renderImages ( ) ; if ( votes === 0 ) { myContainer . removeEventListener ( 'click' , handleClick ) ; renderChart ( ) ; let stringifiedProducts = JSON . stringify ( products ) ; localStorage . setItem ( 'products' , stringifiedProducts ) ; } }
initial image call to populate page
initial image call to populate page
// LOCAL STORAGE BEGINS // step 1 get data ready to store // step 2 set in local storage