H
H
hime22015-08-25 21:53:53
JavaScript
hime2, 2015-08-25 21:53:53

How to solve problems (local storage)?

There is such a code, it's not a basket, it's simpler and easier to explain.
Here is a link to the code .
How can I make sure that the key is not repeated? It can be seen that the information but the key is the same and it turns out that the values ​​are simply replaced. I did not find an answer on the Internet, the key should be generated by itself.
a915fba2b3d740fc9a4e96de26b07865.PNG

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pina, 2015-08-26
@pina

MDN says https://developer.mozilla.org/en-US/docs/Web/API/S...
storage.setItem(keyName, keyValue);
those. your key is the string 'id'
here is the code jsfiddle.net/cfk0uLwp
here the key is the id value
if you need to count the quantity, here is the answer to stackoverflow
stackoverflow.com/questions/2010892/storing-object...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question