Step 1: Hello World
Last updated
Last updated
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()
.
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.
Write this in your Repl:
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.