r/JavaScriptTips • • Oct 15 '22

Javascript Local storage

Hi, I need to set local storage in quiz to save answers after reloading site, can you help me how to do it, thank you.

3 Upvotes

1 comment sorted by

View all comments

0

u/beforesemicolon Oct 15 '22 edited Oct 15 '22

Use this library for an easy API and multi data type support.

https://github.com/beforesemicolon/client-web-storage

Check the example in the README and make the changes to fit your project.

const quizSchema = new Schema("quiz");

quizSchema.defineField("question", String, {required: true});

const quizStore = new ClientStore("quiz", quizSchema);

quizStore.createItem({
  question: “what?”
})