I am currently working on a little browser game and I am using the HTML localStorage to save some data.
I have an empty array that i will later
.push() some data into. I am storing this array in the localStorage but when i try to read from the local storage it doesn't work.
The Chrome Developer Tools console is giving me this error:
"Uncaught SyntaxError: Unexpected token u" when trying to parse the data from localStorage.
Here's the code i am using:
var allContracts = ;
localStorage["allContracts"] = JSON.stringify(allContracts);
allContracts = JSON.parse(localStorage["allContracts"]);
There is more code than this but none of it is interacting with these in any way.
Is there a quirk with localStorage or JSON that i am not aware of and is causing this? (i am not very familiar with JSON or localStorage)
Should i be doing this a different way?
Or am i just missing an obvious mistake?
Thanks in advance :)