I would recommend one of the other questions asked here about how to store objects in localStorage. It helped me a lot as I am implementing a code editor that can store multiple files and last state of the user.
The stackoverflow question
Both answers posted are very valuable.
Some things to take into consideration:
- When do you store data, after each key pressed or after some other specific action/event?
- Use a temporary Javascript data structure or only interact with localStorage directly?