I'm encountering an issue with this code that is resulting in an error message:
Uncaught TypeError: Cannot read property 'push' of null at HTMLButtonElement. (app.js:15)
console.log("Welcome to Notes Taking Website");
// To store notes in the local storage
let addBtn = document.getElementById('addBtn');
addBtn.addEventListener("click", function(e) {
let addTxt = document.getElementById("addTxt");
let notes = localStorage.getItem("notes");
if (notes == null) {
notesObj = [];
} else {
notesObj = JSON.parse(notes);
}
notesObj.push(addTxt.value);
localStorage.setItem("notes", JSON.stringify(notes));
addTxt.value = "";
console.log(notesObj);
})