Lesson 1 of 22 Β· 8 min Β· 1 hands-on step

How Code Runs & Your First Program

What a program actually is, and how to write and run one in under a minute.

What is a program?

A program is a list of instructions a computer follows, in order, exactly as written. The computer won't guess what you meant. That sounds strict, but it's also what makes programming learnable: if something goes wrong, there is always a reason, and you can find it.

JavaScript is the language of the web. It runs in every browser, on servers (Node.js) and in mobile apps, so it's one of the most employable first languages.

Your first line of code

JavaScript Β· try it
Loading…
  • console.log(...) prints whatever you put inside the parentheses.
  • Text in quotes is called a string.
  • The semicolon ; ends the statement (JavaScript is forgiving if you leave it out, but professionals are consistent).

Run it

In the exercise below, press Run (or Ctrl/⌘ + Enter). The output appears on the right, and the tests tell you if you're done.

Pro habit: Run your code often. Professional developers run their code every few minutes, not once at the end. Small steps make bugs easy to find.

When it breaks

You will see errors, often. That's normal and expected. Read the error message: it usually tells you what went wrong and where. For example SyntaxError: missing ) after argument list means you forgot a closing parenthesis.

πŸ§ͺ Practice

Write a program that prints two lines:

  1. Hello, world!
  2. I am learning to code.

Use console.log once for each line.

JavaScript
Loading editor…

Output appears here. Press Run or Ctrl/⌘ + Enter.

βœ… Check your understanding

  1. What does a computer do with your program?

  2. What does console.log("Hi") do?

Create a free account to track your progress.