Lesson 1 of 14 · 5 min

Your first program

A program is a list of instructions the computer follows, one after another, from top to bottom.

The simplest useful instruction in JavaScript prints a message:

console.log("Good morning!");
  • console.log means "write this to the console", the text area where a program shows its output. Here, that is the Output box under the editor.
  • The text goes between quotes. Text in quotes is called a string.
  • The semicolon ; ends the instruction, like a full stop ends a sentence.

Each console.log prints on a new line. Press Run ▶ to run your program and see what it prints.

Your task

Write a program that prints two lines:

  1. Hello, world!
  2. I am learning JavaScript.

Run it to see the output, then press Check my code.

main.js
// Write your first line of JavaScript below.

Discussion

Stuck? Ask here. Be kind, and share hints rather than full answers.

Loading the discussion…