Code Highlights logo

Learn

Getting Started with JavaScript

Arithmetic Operators

Basic arithmetic often comes in handy when programming. These include the following operators and their corresponding symbols:

  • Addition +
  • Subtraction -
  • Multiplication *
  • Division /
  • Modulus %

The first four work how you might guess:

1console.log(1 + 2); // Prints 3
2console.log(3 - 2); // Prints 1
3console.log(9* 2); // Prints 18
4console.log(6 / 3); // Prints 2

The Modulus (%) operator returns the remainder of a division operation. Example:

1let remainder = 17 % 3; // remainder = 2

Instructions

1.

Print the value 5 + 7 to the console.

2.

Print the value 3 * 2 to the console.

3.

Print the value 7 / 2 to the console.

4.

Print the value 5 % 3 to the console.

Sign up to start coding

Already have an account?

Sign In

Course content