I want to create an object that has some keys which come from a variable parameter. Let's say for example that prod_id below is a variable containing some value... I want to create an object which has an attribute with key of that 'prod_id' and value of 1. However this does not work? Is this possible to achieve? if so, how? thanks a heaps
var cart_obj;
cart_obj = {
prod_id : 1
};
localStorage.setItem("cart", JSON.stringify(cart_obj));