Step 1: Hello World

It is programming tradition that the first thing you do in any language is make it say "Hello world!". This is the first thing we'll do in JavaScript, using something called a console.log().


The "console" is where you can see the output of your code. In Repl, you should see a console on the right.

We want to print "Hello world!" to the console. Thankfully in JavaScript there is a built-in way to do this, using a console.log(). You just need to put any text inside quotes, inside the parentheses, and when you run the code you should see that text printed to the console.

Try it out

Write this in your Repl:

console.log('Hello world!');

Click "run" and check the console. You should see "Hello world!" printed out on the right hand side. It'll look something like this:

Don't worry about the undefined. That will go away when we start writing more complex code.

You also might be wondering why there's a semicolon at the end of the code you wrote. Semicolons are used at the end of every statement in JavaScript. The code usually won't break if you forget it, but it's good practice to remember.

Mini challenge

Try to console.log() something different. Try to console.log() several things at once. Does it make a difference if you use double or single quote marks? What happens when you get rid of the quote marks? What happens when you console.log() just a number without quotes?