course content

Course Content

Introduction to JavaScript

Math OperationsMath Operations

Calculation is one of the main capabilities of a computer. JS can work with some mathematical operations that have already been used in this course. Now we will take a closer look at the possibilities of JS.

Math operations

Operations with numbers that JavaScript can perform:

  • addition (+);
  • subtraction (-);
  • multiplication (*);
  • division (/);
  • remainder, or modulo (%);
  • exponent (**).


If you have already used these operations and know how they work, you can read the last header only (Priority of execution of operations) or skip this chapter.

Addition and Subtraction

Multiplication and Division

Remainder (Modulo)

This operation returns the remainder of the division. Performed by the % operator:


This operation raises a number to a certain power. The first number is the base, and the second is the exponent to which it must be raised. Performed by the ** operator:

Priority of execution of operations

Each operation has its own execution priority. The sequence of execution of operations by the interpreter depends on it.


If the operations have the same priority, they will be executed from left to right

You can use parentheses ( ) to increase the priority of execution.


The parentheses () have the largest priority.

The inner parentheses are performed first, and the outer ones after.

Section 3.

Chapter 2