0% found this document useful (0 votes)
19 views

Arithmetic Operators 3

This document introduces arithmetic operators in JavaScript. It lists the main arithmetic operators - add, subtract, multiply, divide, and remainder - and provides examples of how each operator is used. It explains that arithmetic operators allow mathematical calculations to be performed on numbers in code. The add, subtract, multiply, and divide operators work as expected, while the remainder operator returns the number left over after dividing the left number by the right number.

Uploaded by

james hagrid
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Arithmetic Operators 3

This document introduces arithmetic operators in JavaScript. It lists the main arithmetic operators - add, subtract, multiply, divide, and remainder - and provides examples of how each operator is used. It explains that arithmetic operators allow mathematical calculations to be performed on numbers in code. The add, subtract, multiply, and divide operators work as expected, while the remainder operator returns the number left over after dividing the left number by the right number.

Uploaded by

james hagrid
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

INTRODUCTION TO JAVASCRIPT

Arithmetic Operators
Basic arithmetic often comes in handy when programming.

An operator is a character that performs a task in our code. JavaScript has several built-
in in arithmetic operators, that allow us to perform mathematical calculations on
numbers. These include the following operators and their corresponding symbols:

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

The first four work how you might guess:

console.log(3 + 4); // Prints 7


console.log(5 - 1); // Prints 4
console.log(4 * 2); // Prints 8
console.log(9 / 3); // Prints 3
Note that when we console.log() the computer will evaluate the expression inside the
parentheses and print that result to the console. If we wanted to print the characters 3 +
4, we would wrap them in quotes and print them as a string.

The remainder operator, sometimes called modulo, returns the number that remains
after the right-hand number divides into the left-hand number as many times as it
evenly can: 11 % 3equals 2 because 3 fits into 11 three times, leaving 2 as the remainder.

You might also like