上QQ阅读APP看书,第一时间看更新
Moving functionality into individual functions
To resolve the problem, I'd like to get started by creating two new functions:
- fetchNotes
- saveNotes
The first function, fetchNotes, will be an arrow function, and it will not to take any arguments since it will be fetching notes from the filesystem, as shown here:
var fetchNotes = () => {
};
The second function, saveNotes, will need to take an argument. It will need to take the notes array you want to save to the filesystem. We'll set it equal to an arrow function, and then we'll provide our argument, which I will name notes, as shown here:
var saveNotes = (notes) => {
};
Now that we have these two functions, we can go ahead and start moving some of the functionality from addNote up into the individual functions.