Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The given a web page allows the user to add items to a grocery list. A clear button clears the list. The list is also
The given a web page allows the user to add items to a grocery list. A clear button clears the list. The list is also cleared if the page is reloaded. Your goal is to use boalStorage to store the list so reloading the page does not clear the list. Grocery List 1. orange juice 2. milk 3. cereal Examine the given JavaScript The groceries.js file contains several completed functions: - The DomcontentLoaded event handler adds click handlers for the Add and Clear buttons, calls loadListo to bad items from bcalStorage into the grocerylist array, and calls showItem() to display the items in grocerylist. - enableclearButton() enables or disables the Clear button. - showrtem() displays a single item at the end of an ordered list. - addEtnclick() calls showItem() to display the item, adds the item to the grocerylist array, and calls savertem() to save the item to bcalStorage. - clearstnclicko clears the groceryList array and removes all the items from the ordered list. Complete the functions Complete the JavaScript functions below so the list is restored when the page is rebaded: - loadlisto should load a grocery list from bcalStorage and return an array containing each item. Assume the list is stored as a single comma-delimited string. Ex: The list stored as "orange juice, milk, cereal" is returned as the array ["orange juice", "milk", "cereal"]. An empty array should be returned if bcalStorage does not contain a grocery list. - savelist@ should save the given grocerylist array to bcalStorage as a single comma-delimited string. Ex: The array ["orange juice", "milk", "cereal"] should be saved as the string "orange juice, milk, cereal". - clearlisto should remove the grocery list from bcalStorage. All three functions should use the bcalstorage item called "list". 451044.1 DIERZE. Q 3 I y
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started