addNote(note) {
const { title, text } = note;
if (!title || !text) {
throw new Error("Note 'title' and 'text' cannot be blank");
}
// Add a unique id to the note using uuid package
const newNote = { title, text, id: uuidv1() };
// Get all notes, add the new note, write all the updated notes, return the newNote
return this.getNotes()
.then((notes) => [...notes, newNote])
.then((updatedNotes) => this.write(updatedNotes))
.then(() => newNote); // what is the purpose of this line of code
}
I should note that this function exists inside of a class.