javascript comma separators and session storage

204 views Asked by At

I'm new to javascript and so I don't fully understand passing objects... my final product is simple build a comma separated counter that doesn't reset when someone refreshes the page. Guymid build a jsbin demo http://jsbin.com/IyavAPoN/1/edit. It seems that the solution to my problem is pretty straightforward but I can't seem to put them together.

to not reset, someone suggested using sessionStorage which seem to work on another code but I can't seem to incorporate it to the codes that I have as reflected in the JSBin Link.

Any help is much appreciated.

1

There are 1 answers

0
markasoftware On BEST ANSWER

The way to do it is simply do localStorage: http://jsbin.com/ogeYOZa/2/ i basically just store values in localStorage and that's the only difference. However, there are a few more: Instead of just using +=1 to increment values, I use parseInt because localStorage values are strings.