I want to ask a question that is related to my project that I am working on. I have created a shopping cart and it has add and delete buttons to increase and decrease the quantity of the item. Now the problem lies in the adding part as I am unable to increment the quantity in the localStorage
Here's my Code:
For Delete (Working)
function dlte(e)
{
let items = [];
JSON.parse(localStorage.getItem('items')).map(data=>{
if(data.id != e.parentElement.parentElement.children[0].textContent)
{
items.push(data);
}
});
localStorage.setItem('items', JSON.stringify(items));
alert("Item deleted from Cart");
window.location.reload();
}
For Adding (Not working)
function add(e)
{
// I have tried many things but can't figure out how to make it so please help me on this
}
I would be grateful if anyone can step up and help me on this. Thanks in advance!!