I am building a ToDo List but facing an error
VM619:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)
at showNotes (javapractice.html:121)
at javapractice.html:97
showNotes @ javapractice.html:121
(anonymous) @ javapractice.html:97
This is how my code looks Javascript Code
In continuation to above, I want the delete button to work and hence wrote the below code.
else {
notesElm.innerHTML = `Nothing to show fucker`;
}
}
// function to delete note
function deleteNote(index) {
console.log("Deleteme", index);
let notes = localStorage.getItem("notes");
if (notes == null) {
notesObj = [];
} else {
notesObj = JSON.parse(notes);
}
notesObj.splice(index, 1);
localStorage.setItem("notes", JSON.stringify(notesObj));
showNotes();
But the button is not working.
CodePudding user response:
first line of showNotes
function (line 117 on your screen shot), let Notes = …
"Notes" should have a lower "n"