I want to store my radio button values in an object on local storage with index of the object as key of it. What should I do to make fix size array? Also I want to set that object as initial value of my state. I have tried some things, but it does not work out.
2 Answers
var obj = {'one': 1,'two': 2,'three': 3 };
localStorage.setItem('testObject', JSON.stringify(testObject));
var retrievedObject = localStorage.getItem('testObject');
console.log('retrievedObject: ', JSON.parse(retrievedObject));
2 Comments
Community
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
jenish963
I am making an quiz app in which I want to save my selected answers on localstorage but when i come to previous question to reset my answer and then go onto next question then i don't want new item added in my object.