What Am I Doing Bad With Localstorage?
I am doing a time-to-click score table but first I have to localstorage each time I get in a game but I dont know how I have been trying everything but it still not working, I nee
Solution 1:
You probably need to change the line times = JSON.parse(localStorage.times || [])
to times = JSON.parse(localStorage.times) || []
this makes sure that if the parsing fails it will still be an array.
Even better is wrap them with try-catch just in case if your JSON string is corrupted and check if the time is an array in the finally if not set it to empty array.
Post a Comment for "What Am I Doing Bad With Localstorage?"