Programs and Statements

A computer program is a list of statements for a computer to execute. When you write a program, you are essentially writing a list of things you want the computer to do. We refer to each instruction as a statement, and therefore coding (or programming) can be thought of as writing a series of statements. The editor below shows a short program with three statements.

print("Hello world!"); // Statement 1
var x = 5; // Statement 2
print(x + 2); // Statement 3

Once you understand a programming "language", you can think of programming as telling a computer what to do! Throughout this site, we will be using a programming "language" named JavaScript.

What is JavaScript?

JavaScript is the programming "language" that web browsers understand, and therefore it can be thought of as "the language of the web". Chances are, every website that you visit on a regular base is using JavaScript behind the scenes. This site is powered almost entirely by JavaScript! It is a very powerful language, and is relatively easy to learn.

Although JavaScript was originally developed for use in web browsers, it's use has been since expanded. For example, Walmart recently started using JavaScript (Node.js) to run the purchasing portion of their website, and it saved them a ton of money!

JavaScript Syntax

In programming, the syntax of a language is the set of rules that you must follow for the computer to understand your code. Consider the editor below: the first line uses correct syntax, whereas the second line does not use correct syntax. In the output, there is an error because we did not use proper syntax.

print("Hello world!"); // Correct syntax
print "Hello world!"; // Incorrect syntax

In the editor above, change the second line to look like the first line, and things will work! Throughout this tutorial, you will be slowly introduced to the syntax of JavaScript. It will be discussed in further detail on this page.


In programming, variables are like "named containers" for storing data. This allows you to name a piece of data, and refer to it by that name later on. In JavaScript, we define variables by writing statements of the form var [name] = [value]. For example, var x = 5; will store the value "5" in a variable named x, and any time you reference the variable x the code will read it as "5". In JavaScript we can name our variables using letters, numbers, and some characters such as underscores (just make sure your variable name starts with a letter). The editor below shows some code where variables are defined and used.

var x = 5;

var yourName = "John Doe";

var a = 3;
print(a * x);

In the code above, the variables x, yourName and a are defined and used. We use the var keyword to declare or create a variable. Once a variable has been defined, you can actually change its value by using a statement of the form [name] = [new value]. The editor below shows this idea, where a variable is defined and used, then changed and used again.

var x = 6;

x = 8;

x = x + 2;

Another convenient feature of JavaScript is that you can define multiple variables at once by separating each variable definition with commas. The following editor shows this idea.

var x = 5, y = 3, z = -2;



Operators are essentially tools for taking one or two values, and then producing a new value from them. For example, addition is an operator. Notice that \( 5 + 3 = 8 \). The addition "operator" takes 5 and 3 and then returns 8. In programming, there are many useful operators. We will cover a lot of operators on this page. For now, think of operators in a way similar to additon. The editor below shows a few statements that use some basic arithmetic operators.

var x = 5;
print(x + 3); // Addition
print(2 * x); // Multiplication
print(x - 6); // Subtraction


In coding, expressions are just groups of values, variables and operators that will evaluate to a single value. For example, 5 + 3 is an expression. So is x + 5/3. Expressions are used very often in programming. We will be using this term very frequently - just think of it as using old values and operators to create a new value.