I have been experimenting with different ways to add objects to an array in localstorage without overwriting it, but I haven't found a successful solution yet.
My current code stores objects in an array, but it keeps overwriting itself. Can someone please help me identify what I am missing? (I have a feeling it could be quite a lot).
function addEntry() {
var entryTitle = document.getElementById("entryTitle").value;
var entryText = document.getElementById("entryText").value;
var entry = {
"title": entryTitle,
"text": entryText
};
localStorage.setItem("entry", JSON.stringify(entry));
var allEntries = [];
allEntries.push(entry);
localStorage.setItem("allEntries", JSON.stringify(allEntries));
};