My 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
- 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
- Using 3rd Party Modules :: Day Three of "The Complete 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
This is great man! I am inspired to do something similar. Right now I am spending some time learning GO. And I see this is a great way of absorbing what I learn.
Thanks @codero,
Committing to writing every work day this last week was good for me. I wouldn't have studied programming nearly as much if I hadn't done that. I took Saturday off, but will get back to it either this evening or on Monday.
Programming every day for defined sets of time is how I made significant progress and turned from a "wanna-be programmer" to a real programmer.
Nice article, i am taking a course in udemy but of swift and xcode, node js maybe after i think reforce my skills
Thanks Juan Pablo. I easily start Udemy courses, but have difficulty finishing them. That's why I'm documenting my progress here. It will put some social pressure on me to see it through.
I appreciate your comments and your posts. Good to have people like you here on Steemit.
Keep the posts coming. This is a nice thread you created! Look forward to seeing more.
Thanks James. I know that you are also a programmer. What languages do you mostly work in?
Ladder logic. I know lots of different languages. Been doing it since 1991. These days I program machines, Allen Bradley PLCs, delta motion controllers. Used to program in BASIC, VB, Javascrpt, C. I've learned the language doesn't matter, it's the brain, whether or not you can switch up your syntax. In the end you're just moving data. :)
Good response James. It's good to know that the knowledge and skills I'm gaining are transferable between languages.
Nice post dear.
I have just started FOLLOWING you to be part of your blogs.
Hoping you will also
FOLLOW @mrchips
Hey @mrchips,
You kind of look like a bot, as you wrote a generic sounding comment immediately after my article was posted. Nothing against bots, some of them are useful. As for your request, I follow people I'm interested in and who I've socially connected with. I don't do "follow for follow".