1
I’m developing an app for annotations in Javascript, and would like to edit an annotation saved in JSON on localStorage
. This my code is returning only 1 (one) single object and overwrite the others that are stored, I wonder how I can edit only the informed by the user.
My code:
function saveEditedNote(title, text) {
let notesEdit = JSON.parse(localStorage.getItem("notes"))
let note = {
noteTitle : title,
noteText : text
}
localStorage.setItem("notes", JSON.stringify(note))
}
My localStorage:
yes will overwrite even retrieving the previous values in the variable
notesEdit
does nothing with it and arrow a new object in "Notes"– Ricardo Pontual
if I set a new object, the old one will still be present in Storage, I would like to edit the object or else, remove it and add the "edited" object in localSotrage
– irineuSilva
was what I commented, add the new "note" to the "notesEdit" and set the "notesEdit"
– Ricardo Pontual