January 2018
Beginner
658 pages
13h 10m
English
The next step in the process of adding notes will be to add the note to the notes array. The notes.push method will let us do just that. The push method on an array lets you pass in an item, which gets added to the end of the array, and in this case, we'll pass in the note object. So we have an empty array, and we add our one item, as shown in the following code; next, we push it in, which means that we have an array with one item:
var addNote = (title, body) => { var notes = []; var note = { title, body }; notes.push(note);};
The next step in the process will be to update the file. Now, we don't have a file in place, but we can load an fs function and start creating the file.
Up above the addNote function, ...
Read now
Unlock full access