I have trawled the net and stackoverflow for an answer to this question.
How does one retrieve a value from a dynamic key which is also nested in localstorage. I have tried numerous examples and seem to be getting nowhere. I knwo a loop is required to perform the task but which type.
How do I get the 'uniqid' value which has the nested dynamic key SCI-4 from localstorage which reads:
simpleCart_items:{"SCI-4":{"quantity":4,"id":"SCI-4","price":8,"name":"12 fried chicken","flavours":"cola","code":"1001","cartid":"561","uniqid":"592dcd08b5fcc"}}
This allows me to view localstorage.
var obj = localStorage;
Object.keys(obj).forEach(function(key){
var value = obj[key];
console.log(key + ':' + value);
});
How do I iterate to get any value?
The difference in this question is that I seek to get the value from a nested key that has a dynamic value. If the key is not known how does one pull the value? What should the loop look like?