🍭Operations

In JavaScript, you can perform operations on numbers using the following methods:

Addition: You can add two numbers using the + operator. For example:

let x = 10;
let y = 5;
let z = x + y;  // z is equal to 15

Subtraction: You can subtract one number from another using the - operator. For example:

let x = 10;
let y = 5;
let z = x - y;  // z is equal to 5

Multiplication: You can multiply two numbers using the * operator. For example:

let x = 10;
let y = 5;
let z = x * y;  // z is equal to 50

Division: You can divide one number by another using the / operator. For example:

let x = 10;
let y = 5;
let z = x / y;  // z is equal to 2

Remainder: You can find the remainder of a division operation using the % operator. For example:

let x = 10;
let y = 3;
let z = x % y;  // z is equal to 1

In addition to these basic operations, JavaScript also provides a number of methods that you can use to manipulate numbers. For example, you can use the Math.round() method to round a number to the nearest integer, or the Math.pow() method to raise a number to a particular power.

Last updated