js/main.js
// Adds the user's input to the list
Adds the user's input to the list
Adds the user ' s input to the list
function addItem(e) {
  e.preventDefault(); 
  const name = this.querySelector('input[type="text"]').value;
  const item = { name, checked: false };
  items.push(item);
  localStorage.setItem("items", JSON.stringify(items));
  updateDisplay(groceryList, items);
  this.reset(); 
}
function addItem ( e ) { e . preventDefault ( ) ; const name = this . querySelector ( 'input[type="text"]' ) . value ; const item = { name , checked : false } ; items . push ( item ) ; localStorage . setItem ( "items" , JSON . stringify ( items ) ) ; updateDisplay ( groceryList , items ) ; this . reset ( ) ; }
Adds the user's input to the list
Adds the user ' s input to the list
// Preventing page refresh on submit // Clears form input field