Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

How to replace a value in localstorage using javascript

let productCost = +document.getElementById('projectcost').value;
let productQty = +document.getElementById('productQty'+id).value;
let product_list = JSON.parse(localStorage.getItem('myItems') ?? "[]");
                       .filter(({productId}) => productId != id)
                       .concat({productId: id, productCost, productQty});
localStorage.setItem('myItems', JSON.stringify(product_list));
 
PREVIOUS NEXT
Tagged: #How #replace #localstorage #javascript
ADD COMMENT
Topic
Name
8+1 =