Notes
=
sign is an assignment operator and it assigns a value to a variable.
let x = 5;
The operator +
adds two variables.
let x = 5;
let y = 12;
let z = x + y;
document.write(z);
Output: 17
The operator -
subtracts a variable from a variable.
let x = 12;
let y = 8;
let z = x - y;
document.write(z);
Output: 4
The operator * multiples a variable by another variable.
let x = 4;
let y = 5;
let z = x * y;
document.write(z);
Output: 20
The operator / divides a variable by a variable.
let x = 12;
let y = 2;
let z = x / y;
document.write(z);
Output: 6
The operator % finds the remainder when a number is divided by another number.
let x = 13;
let y = 5;
document.write(x%y);
Output: 3
The operator ++ increases a variable or a number by 1.
let x = 7;
x++;
document.write(x);
Output: 8
let x = 7;
++x;
document.write(x);
Output: 8
The operator -- decreases a variable or a number by 1.
let x = 12;
x--;
document.write(x);
Output: 11
let x = 5;
--x;
document.write(x);
Output: 4