I have an array i stored(parsed it as json) in localstorage. I got it back into an object, removed some items from it and i need to update the key with the new values in the local storage.
var counter = [0,1,2];
var count = counter[0];
var questions = localStorage.getItem('questions');///questions had been stored in local storage with another function
console.log(questions);
questions = $.parseJSON(questions);
if (questions != 0){
$('.question').html(questions[count]['question']);
var options = (questions[count]['options']);
options.forEach(function (item) {
$('.options').html(item);
});
var index = counter.indexOf(1);
questions = questions.splice(index, 1);
console.log(questions);
localStorage.removeItem('questions);
counter = counter.splice(index, 0);
Now, when i remove the question key from the local storage, the whole question array is deleted, however, i only need to delete the particular question array that was passed.