January 2018
Beginner
658 pages
13h 10m
English
Let's work on this method. Now, the first thing I'll do is fill out, inside of app.js, a variable called note which is going to store the return value from getNote:
} else if (command === 'read') { var note = notes.getNote(argv.title);
Now, this could be an individual note object or it could be undefined. In the next line, I can use an if statement to print the message if it exists, or if it does not exist. I'll use if note, and I am going to attach an else clause:
} else if (command === 'read') { var note = notes.getNote(argv.title); if (note) { } else { }
This else clause will be responsible for printing an error if the note is not found. Let's get started with that first since it's pretty simple, console.log ...
Read now
Unlock full access