JS Cookies SOLVED
What should happen: If you close the page, then reopen it, you coins and the skyscraper should the same as when you closed it.
No one stores game data in cookies.
Use a proper storage and retrival mechanism, like IndexedDB:
Yeah, it might take some time to learn IndexedDB itself, but afterward, it works very well, and libs make it much simpler. Just don't store classes directly, as they will be serialized into plain objects.
As for how you store arrays, I'm not sure about the specific library that you're using; you might be interested in trying out that lib ^, storing an array is as simple as writing
await db.store("array", [ 1, 2, 3 ]) and
const array = await db.get("array")
But it's great to hear that it helped, good luck!
you can only store strings. You can use
JSON.parse() to parse your arrays and objects and
JSON.stringify() to convert to a string 'object'
Number() for your parsing number needs.
okee dokey, I put it in and now I got an error:
Thanks for your help too @sammightyt ;)
oooooooh whoops I forgot to mention that my floors is an array of objects, not numbers or strings. Would that affect the parsing (like would it parse to int or string or something instead of an object)
secondly, I didn't even get an error on repl.it, but from what it looks like it seems like the error is about what i said above. @Coder100
Somewhat irrelevant: Line 36, 42, 47, 53- I would put the prices on the buttons:
[...createButton("1. Buy Small Gen- $10k)]
and so forth.