Back to Course

## Introduction to JavaScript

0% Complete
0/0 Steps
1. JavaScript: Basics
9Topics
|
10 Quizzes
2. JavaScript: Variables
9Topics
|
10 Quizzes
3. JavaScript: Conditional Statements
10Topics
|
11 Quizzes
4. JavaScript: Functions
10Topics
|
11 Quizzes
5. JavaScript: Scope
6Topics
|
7 Quizzes
6. JavaScript: Arrays
11Topics
|
12 Quizzes
7. JavaScript: Loops
8Topics
|
9 Quizzes
8. JavaScript: High Order Functions
3Topics
|
4 Quizzes
9. JavaScript: Iterators
3Topics
|
3 Quizzes

#### Participants 24

In Progress
Lesson 1, Topic 5
In Progress

# JavaScript: Arithmetic Operators

##### Yasin Cakal 26 Oct 2021
Lesson Progress
0% Complete

Basic arithmetic operations are commonly used in programming.

In our code, an operator is a character that performs a task. JavaScript includes various built-in arithmetic operators that allow us to do mathematical operations on integers. These include the following operators and their corresponding symbols:

1. Add: `+`
2. Subtract: `-`
3. Multiply: `*`
4. Divide:`/`
5. Remainder: `%`

The first four execute as you may expect:

``````console.log(13 + 7); // Prints 20
console.log(9 - 1);  // Prints 8
console.log(9 * 2);  // Prints 10
console.log(12 / 3); // Prints 4
``````

When we use `console.log()`, the computer will evaluate the expression within the parenthesis and print the result to the `console`. If we wanted to print the characters 13 and 7, we would enclose them in quotation marks and print them as a `string`.

``````console.log(12 % 5); // Prints 2
console.log(36 % 6); // Prints 0``````

The `remainder` operator, also known as `modulo`, returns the `number` that remains after dividing the right-hand number into the left-hand number as many times as it can evenly. Because 5 fits inside 12 two times, leaving 2 as the remainder, `12%5 = 2`.

Quizzes