Learnyounode: Exercise 1
The typical “Hello world” challenge.
Write a program that prints the text “HELLO WORLD” to the console (stdout).
In order to write a NodeJS program, you will need to create a file with the extension .js and run it with the command:
$ node program.js
Do this to write programs and experiment on your own, but for the purposes of the Learnyounode tutorial, you will be running and verifying that your code using Learnyounode and a command line argument.
Before we attack the first challenge, you will need to know how to verify and pass each stage.
How To Pass Each Challenge
To pass each exercise in the tutorial, you will need to follow these steps:
1. Run Learnyounode from the command line.
2. Select an exercise from the list.
3. Read and follow the instructions.
4. To verify you’ve completed the challenge, provide ‘learnyounode’ with the command line argument ‘verify’.
$ learnyounode verify program.js
Contribute to learnyounode development by creating an account on GitHub.github.com
Prints to stdout with newline. Multiple arguments can be oassed, with the first used as the primary message and all additional used as substitution values similar to printf(3) (the arguments are all passed to util.format())
In this example, console.log() is passed a string “HELLO WORLD” which it prints to stdout.
Watch what happens when I try running this program with Node from the terminal:
The string passed as an argument to console.log is printed to the terminal (stdout). If we want to try verifying our result, this is what happens:
Learnyounode simulates the running of this program, but checks the results with the expected results. In this case, we passed. You are provided with an official solution only when you pass the test.