Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Mathematical Operations

Course Content

Introduction to JavaScript

## Mathematical Operations

JavaScript can perform the following operations with numbers:

• Addition (`+`);
• Subtraction (`-`);
• Multiplication (`*`);
• Division (`/`);
• Remainder, or Modulo (`%`);
• Exponent (`**`).

Note

If you are already familiar with these operations and how they work, skip to the last section (Priority of Execution of Operations) or proceed with this chapter.

### Remainder (Modulo)

This operation returns the remainder of a division and is performed using the `%` operator:

### Exponent

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. It is performed using the `**` operator:

# Priority of Execution of Operations

Each operation has its execution priority, and the sequence of execution depends on it.

Note

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

You can use parentheses `( )` to modify the priority of execution:

Note

Parentheses `()` have the highest priority. Inner parentheses are evaluated first, followed by outer ones.

Everything was clear?

Section 3. Chapter 2