DEV Community

Discussion on: Learn the Storage API by Building a Note Taking App

Collapse
 
jimgregory profile image
Jim Gregory • Edited

Thanks, that was very useful.

Here's another way to delete the note that avoids looping through all the elements:

function deleteNote() {
    const note = notes.value;
    const options = document.querySelectorAll('options');
    window.localStorage.removeItem(note);
    editor.value = '';
    notes.removeChild(notes[notes.selectedIndex]);
}
Collapse
 
healeycodes profile image
Andrew Healey

This is really neat! I felt like there should have been a way to avoid that iteration. Thanks 👍