1function addEntry() {
2 // Parse any JSON previously stored in allEntries
3 var existingEntries = JSON.parse(localStorage.getItem("allEntries"));
4 if(existingEntries == null) existingEntries = [];
5 var entryTitle = document.getElementById("entryTitle").value;
6 var entryText = document.getElementById("entryText").value;
7 var entry = {
8 "title": entryTitle,
9 "text": entryText
10 };
11 localStorage.setItem("entry", JSON.stringify(entry));
12 // Save allEntries back to local storage
13 existingEntries.push(entry);
14 localStorage.setItem("allEntries", JSON.stringify(existingEntries));
15};