The basics of syntax

INPUT · Slides

Your first JavaScript

01 / 06

What is JavaScript?

JavaScript (JS for short) is the language that makes a web page do things.

A button you press and the page changes, a form that tells you off the moment you mistype something — nearly all of that movement is JS.

In this course you will pick up the ideas that everything in programming is built on, and you will pick them up in JS.

02 / 06

A program runs from the top down

A program runs one line at a time, from the top, in the order you wrote it.

Code that looks hard is, in the end, just small instructions stacked up. Let us learn the first one.

03 / 06

Showing something with console.log

The first instruction to learn is console.log(). It puts whatever you write between the brackets on the screen.

The place it appears is called the console. On this screen it shows up on the right, or underneath if you are on a phone.

console.log("Hello!");

Result

Hello!

04 / 06

Wrap text in "

When you want to show some text, the rule is to wrap it in " (a double quote).

If you forget, JS thinks it is the name of something and you get an error.

console.log("Good morning");

Result

Good morning

05 / 06

A semicolon at the end of a line

At the end of an instruction you write ; (a semicolon). It is the marker that says one instruction ends here.

Write two lines and you get two lines of output, top to bottom.

console.log("Good morning");console.log("Good night");

Result

Good morning
Good night

06 / 06

Now have a go

From here you get your hands on it.

First 3 questions to trace the shape, then 10 to practise. Errors are fine — you just fix them. That is what programming is.