Free Code Camp and Learning Express.js: Hello World

This one was fairly simple, and Quincy explained it in the video that’s part of the assignment, so I won’t spend much time on it. Here are the directions and hints:

Exercise 1 of 8

Create an Express.js app that outputs “Hello World!” when somebody goes to /home.

The port number will be provided to you by expressworks as the first argument of the application, ie. process.argv[2].



This is how we can create an Express.js app on port 3000, that responds with a string on ‘/’:

var express = require('express')
 var app = express()
 app.get('/', function(req, res) {
 res.end('Hello World!')

Please use process.argv[2] instead of a fixed port number:


One thing I did that Quincy didn’t was assign the port to a variable rather than just referencing process.argv[2]. As he noted, the slash sign in the call to app.get is for the root, and to go to home from the root it would be /home and we add the word home. That’s it for this one!

var express = require('express')
var port = process.argv[2];

var app = express()
app.get('/home', function(req, res) {
res.end('Hello World!')

And that’s it!  See you next time!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s