edubun
English
1 / 12

1 / 12 · Intro

What programming is

A program is a list of instructions, and JavaScript carries them out one statement at a time, from the top line to the bottom.

Jump to the 10 practice questions

You will learn

  • Follow a program one statement at a time, top to bottom
  • Use comments and read the first error messages

1Explain

One statement, one line

Read it piece by piece. console is the place where a program writes messages for the person running it. .log means "write one line there." The parentheses hold what should be written, and the double quotes mark Hello, world! as text rather than as more code. The semicolon at the end closes the instruction, the way a full stop closes a sentence.

console.log("Hello, world!");
Output
Hello, world!

2Explain

Top to bottom

A program with several statements runs them in order. The second line does not start until the first has finished. The program below prints three lines, and they come out in the same order as the code:

Press Next step: the orange line runs next, and each console.log adds one line to the output.

  1. console.log("Wake up");
  2. console.log("Brush teeth");
  3. console.log("Eat breakfast");
  4. // prints:
  5. // Wake up
  6. // Brush teeth
  7. // Eat breakfast
Variables
Output
Wake up
Brush teeth
Eat breakfast

3Problem

Two lines or one?

What does this print?

console.log("Hi");
console.log("there");

Hint

Each console.log prints its own line, in the order of the code.

Solution

Answer: Hi, then there on the next line

Each console.log prints its own line, and statements run from top to bottom.

4Explore

What goes inside console.log( )

Pick what goes inside the brackets. Text in quotes is copied, a sum without quotes is worked out, commas put a space between values, and a word without quotes is read as a name.

Inside console.log( )
console.log("Hello, world!");
Output
Hello, world!

5Explain

// and /* */ comments

In the example above, the lines starting with // are comments. JavaScript skips everything from // to the end of that line, so you can write notes to yourself or to other readers. For a note that spans several lines, start it with /* and end it with */. Comments are also a handy way to switch a line off without deleting it: put // in front of it and it no longer runs.

console.log("Snack");
// console.log("Nap");
console.log("Walk");
/* console.log("Bath");
console.log("Bed"); */
Output
Snack
Walk

6Problem

How many lines?

How many lines does this print?

console.log("A");
console.log("B");
/* console.log("C");
console.log("D"); */
console.log("E");

Hint

Lines inside /* */ do not run, however many there are.

Solution

Answer: 3

C and D are inside a /* */ comment. A, B and E print.

7Practice

Hello, world!

Write one statement that prints Hello, world! exactly, with the capital H and the comma.

Expected output
Hello, world!
Your code
// Print the words Hello, world!
// on the line below.
Hint

Copy the text exactly inside double quotes: capital H, the comma and the exclamation mark.

A solution
console.log("Hello, world!");

8Practice

Put the lines in order

Change the order of the statements so the output reads Line 1, Line 2, Line 3.

Expected output
Line 1
Line 2
Line 3
Your code
console.log("Line 3");
console.log("Line 1");
console.log("Line 2");
Hint

The output follows the order of the statements, so move whole lines.

A solution
console.log("Line 1");
console.log("Line 2");
console.log("Line 3");

9Problem

A misspelled name

You run consol.log("Hi"). What happens?

Hint

Is there anything called consol?

Solution

Answer: It stops with a ReferenceError: consol is not defined

There is nothing called consol, so JavaScript reports that the name is not defined.

10Problem

A missing quote

A line is missing its closing quote: console.log("Hi);. What kind of error is this?

Hint

The code breaks the grammar of the language before anything runs.

Solution

Answer: SyntaxError

The code breaks the grammar of the language, so it is a SyntaxError and nothing runs.

11Explain

Reading your first errors

consol.log("Hi");
Error message
ReferenceError: consol is not defined (line 1)
  1. The word before the colon names the kind of error: ReferenceError, TypeError, SyntaxError.
  2. After the colon: what went wrong, usually with the name involved.
  3. The line number shows where the program stopped. A SyntaxError stops it before any line runs.

A misspelled name: JavaScript knows console but not consol, so it stops with a ReferenceError on line 1.

console.log("Ready");
console.log("Go);
Error message
SyntaxError: Invalid or unexpected token
  1. The word before the colon names the kind of error: ReferenceError, TypeError, SyntaxError.
  2. After the colon: what went wrong, usually with the name involved.
  3. The line number shows where the program stopped. A SyntaxError stops it before any line runs.

A missing closing quote breaks the grammar. It is a SyntaxError, so not even line 1 runs.

12

Summary

  • A program is a list of instructions run from top to bottom.
  • console.log("text") prints one line.
  • Text goes inside quotes; the quotes are not printed.
  • // starts a comment; JavaScript skips it.
  • JavaScript is case sensitive.

Next unitValues and console.log
Full text · The whole lesson as one text

Instructions a computer can follow

A recipe says "crack two eggs, whisk them, pour them into the pan." A person reading it fills in a lot on their own: which bowl to use, how hard to whisk, what to do if a piece of shell falls in. A computer fills in nothing. It does exactly what the instructions say, in exactly the order they are written, and it stops with an error the moment an instruction makes no sense to it. Programming is the work of writing instructions precise enough for a machine to follow.

Those instructions are written in a programming language. A programming language has a small vocabulary and strict grammar, so that every line means one thing and only one thing. This course uses JavaScript. It is the language built into every web browser, which means you already have everything you need to run it. The practice boxes on these pages run your code right inside the browser you are reading with. JavaScript also runs outside browsers, in tools such as Node.js, and the basics you learn here work the same way there.

Your first line of code

Almost every programming course starts by making the computer print a message. In JavaScript that looks like this:

console.log("Hello, world!");

Read it piece by piece. console is the place where a program writes messages for the person running it. .log means "write one line there." The parentheses hold what should be written, and the double quotes mark Hello, world! as text rather than as more code. The semicolon at the end closes the instruction, the way a full stop closes a sentence. One complete instruction like this is called a statement. When it runs, the console shows a single line: Hello, world! The quotes are not printed. They only tell JavaScript where the text starts and ends.

Top to bottom, one statement at a time

A program with several statements runs them in order. The second line does not start until the first has finished. The program below prints three lines, and they come out in the same order as the code:

console.log("Wake up");
console.log("Brush teeth");
console.log("Eat breakfast");
// prints:
// Wake up
// Brush teeth
// Eat breakfast

Swap the first two lines and the output swaps too. This sounds obvious, but a large share of beginner bugs come from statements in the wrong order: using a value before it has been calculated, or printing a total before adding the last item.

Comments are notes for people

In the example above, the lines starting with // are comments. JavaScript skips everything from // to the end of that line, so you can write notes to yourself or to other readers. For a note that spans several lines, start it with /* and end it with */. Comments are also a handy way to switch a line off without deleting it: put // in front of it and it no longer runs.

When something goes wrong

JavaScript is case sensitive: console.log works, but Console.log and console.Log do not. A misspelled name such as consol.log stops the program with a message like ReferenceError: consol is not defined. A missing closing quote or bracket gives a SyntaxError, which means the code is not valid JavaScript at all, so nothing runs. Error messages look alarming at first, but they are the computer telling you where it got stuck. Read the first line of the message, find the name it mentions, and compare it with your code character by character.

How the practice boxes work

Each practice box has your code on the left and the output on the right (below it on a phone). Play runs the code, and Ctrl+Enter or Cmd+Enter does the same from the keyboard. Check runs the code and compares each printed line with the expected answer, so spelling, capital letters and spaces inside the line all count. Start over brings back the original code. The code runs in a sealed frame, so you cannot break anything by experimenting.

BackgroundJavaScript was invented by Brendan Eich at Netscape and first appeared in the Netscape Navigator 2 browser. Work on a shared standard began in November 1996, and Ecma International adopted the first edition of the standard, called ECMAScript and numbered ECMA-262, in June 1997. The language is still updated once a year. The 17th edition, ECMAScript 2026, was published in June 2026. Browser makers build their JavaScript engines to follow that document.
Key points
  • A program is a list of instructions run from top to bottom.
  • console.log("text") prints one line.
  • Text goes inside quotes; the quotes are not printed.
  • // starts a comment; JavaScript skips it.
  • JavaScript is case sensitive.

Practice questions from What programming is on edubun

Embed this quiz

Free to embed. Please keep the credit line.

Sources for this course (2)
  • MDN Web Docs, JavaScript Guide (developer.mozilla.org/en-US/docs/Web/JavaScript/Guide, chapters Introduction, Grammar and types, Control flow, Loops and iteration, Functions, Expressions and operators, Numbers and strings, Indexed collections, Working with objects; checked 2026-10-17)
  • Ecma International, ECMA-262 ECMAScript 2026 Language Specification, 17th edition, June 2026 (tc39.es/ecma262 and ecma-international.org/publications-and-standards/standards/ecma-262, checked 2026-10-17).

Checked: 2026-10-17