Я пытаюсь добавить sh элемент в объект Note, но получаю сообщение об ошибке: «Uncaught TypeError: noteObj.pu sh не является функцией» - PullRequest
0 голосов
/ 20 июня 2020
let addBtn = document.getElementById('addBtn');
let addTxt = document.getElementById('addTxt');


addBtn.addEventListener('click', function (e) {

    let addTxtVal = addTxt.value || '';
    let notes = localStorage.getItem('notes');
    if (notes == null) {
        noteObj = [];
    }
    else {
        noteObj = JSON.parse(notes);
    }
    noteObj.push(addTxtVal);
    localStorage.setItem('notes', JSON.stringify(noteObj));

})
...