What is the purpose of this line of code

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.

It returns the note that you’re saving. The overall function needs to return something, that’s a sensible thing to return in this case
.