Interactive online courses HTML Academy
2026-03-09 14:11 Diff

In order to write universal programs, we had to learn the following:

  1. get previously unknown data,
  2. save this data to variables for further use,
  3. process data or perform operations on them.

We are now done with the first two items. Let’s proceed to operations now. Take a look at this command:

50 + 100;

This is an operation. It consists of an operation sign, +, and two operands, 50 and 100.

The sign defines what is going to happen to the operands. In the command above, we use a plus sign, which means that it’s an addition operation and the operands will be added up. The command will return the addition result, 150.

Addition is a binary operation since it only works with two operands. Binary operations are the most commonplace ones. However, there are unary operations with just one operand and ternary operations with three operands.

We can use variables as operands:

breakfastCalories + dinnerCalories; milkInGrams * 0.5; 50 + waterInGrams;

Different operations can be performed on different types of operands, so it’s important to understand the types of data stored in variables. The console.log() command really helps here.

Let’s practice on numerical operations. Here are some of them:

Addition+Subtraction-Multiplication*Division/