-
Notifications
You must be signed in to change notification settings - Fork 583
Open
Description
Description:
The cart is managed by string-parsing a single cookie. Cookies have a 4KB limit and are sent with every HTTP request, which is inefficient for storing large amounts of data like a shopping cart.
Improved Code: - contentDetails.js
buttonTag.onclick = function() {
let cart = localStorage.getItem("cart") ? JSON.parse(localStorage.getItem("cart")) : [];
cart.push(id);
localStorage.setItem("cart", JSON.stringify(cart));
document.getElementById("badge").innerHTML = cart.length;
}
Metadata
Metadata
Assignees
Labels
No labels