I'm trying delete individual cart items from cart, which is saved in localStroage, so far I'm only able to delete whole array via removeitem() or clear(), but I want to delete selective item by item id. Mean while I'm getting below error if I used splice. I'm learning so let me know if I need to provide more information.
deleteProduct: (index) => {
const existingEntries = JSON.parse(localStorage.getItem("cartData"));
existingEntries.splice(index, 1);
localStorage.setItem("cartData", JSON.stringify(existingEntries));
}
let cartData = window.localStorage.getItem('cartData');
const cart = {
state: {
cartData: cartData ? JSON.parse(cartData) : {
foods: [],
totalPrice: [],
Quantities: []
},
},

