My Programming Progress: Day Four of "The Complete Node.js Developer Course"
javascript·@matthewdavid·
0.000 HBDMy Programming Progress: Day Four of "The Complete Node.js Developer Course"
 # Strategy for learning Node.js Each day I am going through some of the Node.js Udemy course and then writing about it here on Steemit. Some days I go through just one section, other days I get through more. It just depends on how long each section is and how much time it takes to practice what is covered in the section. ## Previously * [My Programming Goals: javascript proficiency, node.js and databases](https://steemit.com/programming/@matthewdavid/my-programming-goals-javascript-proficiency-node-js-and-databases) * [My Programming Progress: Day One of "The Complete Node.js Developer Course"](https://steemit.com/javascript/@matthewdavid/my-programming-progress-day-one-of-the-complete-node-js-developer-course) * [My Programming Progress: Day Two of the Complete Node.js Developer Course - require](https://steemit.com/javascript/@matthewdavid/my-programming-progress-day-two-of-the-complete-node-js-developer-course-require) * [Using 3rd Party Modules :: Day Three of "The Complete Node.js Developer Course"](https://steemit.com/javascript/@matthewdavid/using-3rd-party-modules-day-three-of-the-comple-node-js-developer-course) # Today's progress Today, I got through sections 12, 13 and 14. The topic was "Getting Input From The User". Because we are just starting out, the input is entered in the Terminal after the initial node command. Like this: ``` node app.js add --title=test --body="this is a test note" ``` So these are command line arguments. At this point, nothing is being done in the brower, but all in the Terminal. I was able to complete the challenges in the video without any problems. We created simple "dummy" functions that just printed out statements to the Terminal console. The functions were stored in the notes.js module that I created and required at the top of app.js For today, I'll just share the completed code. ### app.js ``` console.log('starting app'); const fs = require('fs'); const _ = require('lodash'); const yargs = require('yargs'); const notes = require('./notes.js'); const argv = yargs.argv; var command = argv._[0]; console.log('Command: ', command); console.log('Yargs: ', argv); if (command === 'add') { notes.addNote(argv.title, argv.body); } else if (command === 'list') { notes.getAll(); } else if (command === 'read') { notes.getNote(argv.title); } else if (command === 'remove') { notes.removeNote(argv.title); } else { console.log('Command not recognized') } ``` ### notes.js ``` console.log('starting notes.js'); var addNote = (title, body) => { console.log('Adding note', title, body); } var getAll = () => { console.log('Getting all notes'); } var getNote = (title) => { console.log('Reading note: ', title); } var removeNote = (title) => { console.log('Removing note: ', title); } module.exports = { addNote, getAll, getNote, removeNote } ``` ### Test and verify I tested everything and it worked just like it did in the video. When using the terminal to give user input, such as to remove a note, the app would give the correct output.  ### To Sum It Up I'm feeling more comfortable with writing code everyday. Though, I had to push myself to keep working on it this evening, as it would have been easier to just relax instead of going through the exercises. If I hadn't committed to my study plan, I would have been more strongly tempted to put off studying programming. Once I get into it, I enjoy it. Sometimes getting started is the most difficult part. I appreciate the encouragement I've received here on Steemit as I go through this process of learning Node.js and how to build useful apps that store data. #### Thanks for Reading --- @matthewdavid