JavaScript Basics

JavaScript is the programming language of the web. It runs in every browser and makes pages react to what people do. These lessons teach you to program from zero: you write code, run it, and get it checked on the spot.

0 of 13 lessons done
Start Course

Part 1First Steps

  1. Hello, ConsoleRun your first JavaScript, print text and numbers with console.log and learn what a statement is.
  2. VariablesStore values under a name with let and const, and change them later.
  3. Numbers and MathCalculate with numbers, use the remainder operator and update variables with shortcuts like +=.
  4. StringsJoin text, insert values with template literals and use string properties and methods.

Part 2Controlling the Flow

  1. Making DecisionsCompare values and run different code with if, else if and else.
  2. LoopsRepeat code with for and while loops, count up and down, and add up a total.

Part 3Building Blocks

  1. FunctionsPackage code into reusable functions with parameters and return values.
  2. ArraysKeep a list of values in an array, read items by position, add and remove items, and loop over them.
  3. Working With ListsTransform arrays with map, pick items with filter and learn arrow functions.
  4. ObjectsGroup related values in an object with named properties, read and change them, and store objects in arrays.

Part 4JavaScript on a Web Page

  1. Changing the PageConnect JavaScript to a web page: find elements with querySelector and change their text and style.
  2. Reacting to ClicksMake pages interactive with addEventListener, respond to button clicks and read what a visitor typed.
  3. Project: A To-Do ListBuild a working to-do list that adds items from a text box, using events, the DOM and everything else from the course.

Your Certificate

Finish every lesson in this course to unlock a certificate with your name on it.

What you will learn

This course teaches the ideas found in every programming language, using JavaScript. The first lessons run in a console, where you can see exactly what your code prints. The last lessons connect JavaScript to a web page.

Before you start

You need no programming experience. For the last three lessons it helps to know a little HTML, which you can pick up in HTML Basics.

How the lessons work

Write your code in the editor and press Run (or Ctrl+Enter) to see what it prints. Errors show with their line number, and the line is highlighted in the editor. Check My Code runs your program and tests the result, including calling the functions you wrote with different inputs.

Frequently asked questions

Is this JavaScript course free?

Yes. Every lesson is free, with no account and no limits.

Do I need to know HTML or CSS first?

Not for most of the course. The first eleven lessons are pure programming and run in a console. The last three work with a web page, where knowing basic HTML helps.

Where does my code run?

In your own browser, inside a sandbox that is separated from the rest of the site. Nothing you type is sent to a server.

What happens if I write a loop that never ends?

The editor stops code that runs for too long and tells you, so an endless loop cannot freeze the page.

Is JavaScript the same as Java?

No. They are two different languages with similar names. JavaScript is the one that runs in web browsers.

Do I get a certificate?

Yes. Finish every lesson to unlock a certificate of completion with your name on it. It is a personal record, not an accredited qualification.