| 148 | |
| 149 | // this function will delete note, and show remaining notes. |
| 150 | function deleteNote(index){ |
| 151 | let notes = localStorage.getItem('notes'); |
| 152 | let notesObj; |
| 153 | |
| 154 | if(notes == null){ |
| 155 | notesObj = []; |
| 156 | } |
| 157 | else{ |
| 158 | notesObj = JSON.parse(notes); |
| 159 | } |
| 160 | // splice will remove element from index, here splice(index from where it should be remove, howmany element shoudl be remove) |
| 161 | notesObj.splice(index, 1); |
| 162 | localStorage.setItem('notes', JSON.stringify(notesObj)); |
| 163 | showNotes(); |
| 164 | } |
| 165 | |
| 166 | let search = document.getElementById('searchTxt'); |
| 167 | |