๐ญ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 15Subtraction: 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 5Multiplication: You can multiply two numbers using the * operator. For example:
let x = 10;
let y = 5;
let z = x * y; // z is equal to 50Division: 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 2Remainder: 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 1In 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