Arithmetic Operators in JavaScript

Arithmetic operators in JavaScript for performing arithmetic operations on numbers (both whole and fractions).

Arithmetic
Operator
Arithmetic
Operation
Example
+Additionlet a = 200
let b = 100
let c = a + b
output : c = 300
*Multiplicationlet a = 200
let b = 2
let c = a * b
output : c = 400
Subtractionlet a = 200
let b = 100
let c = a – b
output : c = 100
/Divisionlet a = 100
let b = 2
let c = a / b
output : c = 50
%Remainder (Modulus)let a = 100
let b = 3
let c = a % b
output : c = 1
++Incrementlet a = 100
a++
output : a = 101
– –Decrementlet a = 100
a- –
output : a = 99
**Power (Exponentiation)let a = 10
let b = 2
let c = a ** b
output : c = 100

Incremental Assignment

				
					Operator : '+='

let a = 10
a += 10 //Increments the value of 'a' by 10 
console.log("a = ",a);

output:-> a = 20
				
			

Decremental Assignment

				
					Operator : '-='

let a = 100
a -= 10 //Decrements the value of 'a' by 10 
console.log("a = ",a);

output:-> a = 90
				
			

Multiplication Assignment

				
					Operator : '*='

let a = 10
a *= 10 //Multiplies the value of 'a' by 10
console.log("a = ",a);

output:-> a = 100
				
			

Division Assignment

				
					Operator : '/='

let a = 50
a /= 10 //Divides the value of 'a' by 10
console.log("a = ",a);

output:-> a = 5
				
			

Exponentiation Assignment

				
					Operator : '**='

let a = 5
a **= 2 //Assigns "the a to the power of 2" to 'a'
console.log("a = ",a);

output:-> a = 25
				
			

Modulus Assignment

				
					Operator : '%='

let a = 75
a %= 2 //Assigns "the remainder of division a/2" to 'a'
console.log("a = ",a);

output:-> a = 1
				
			

Assignment

  • Declare multiple number variables in a ‘.js’ file and perform various arithmetic operations on those. Print the output in console.