i need help!
I am looking to uses chrome local storage in one of my apps. Basically this is supposed to be a shopping list app that store locally previously entered items as an object in JavaScript.
i must be doing something wrong because when there is nothing in local storage and i add an item i gets saved fine but then whenever i add a second item, the previous item gets replaced.
Here's my code so far
function useLocalStorage(shoppingListItem){
let shoppingApp = {};
if (localStorage.getItem(shoppingApp) === null){
shoppingApp.shoppingList = [];
}
else {
shoppingApp.shoppingList = JSON.parse(localStorage.getItem('shoppingApp.shoppingList'));
}
shoppingApp.shoppingList.push({
shoppingListItem : shoppingListItem,
checked : false,
});
localStorage.setItem(shoppingApp.shoppingList.shoppingListItem,
JSON.stringify(shoppingApp.shoppingList));
}