JavaScript Arithmetic Operators
There are two types of Arithmetic Operators in JavaScript; Binary and Unary. Binary Operators require two operands; one on each side of the Operator. Unary Operators are pre-pended or appended to a single operand. The examples below explain how each operator is used and display code you can use to evaluate equations using each type.
Binary Operators:
Addition Operator
This is simply a standard addition equation.
var a = 50;
var b = 24;
var solutionValue = a + b;
document.write("<p>The result of the solutionValue variable after the addtition operator is evaluated is " + solutionValue + "</p>");

Subtraction Operator
This is simply a standard subtraction equation.
var a = 50;
var b = 24;
var solutionValue = a - b;
document.write("<p>The result of the solutionValue variable after the subtraction operator is evaluated is " + solutionValue + "</p>");

Multiplication Operator
This is simply a standard multiplication equation.
var a = 50;
var b = 24;
var solutionValue = a * b;
document.write("<p>The result of the solutionValue variable after the multiplication operator is evaluated is " + solutionValue + "</p>");

Division Operator
This is simply a standard division equation, but because 50 is not evenly divisible by 24 you get a remainder.
var a = 50;
var b = 24;
var solutionValue = a / b;
document.write("<p>The result of the solutionValue variable after the division operator is evaluated is " + solutionValue + "</p>");

Modulus Operator
For those of you who aren’t familiar with Modulus, it’s the reminder after the left operand is divided by the right operand.
var a = 50;
var b = 24;
var solutionValue = a % b;
document.write("<p>The result of the solutionValue variable after the modulus operator is evaluated is " + solutionValue + "</p>");

Unary Operators:
Increment Operator
The Increment Operator adds an increment of 1 when placed before the variable. It’s denoted by two plus signs.
var onhandQuantity = 100;
var newInventory = ++onhandQuantity;
document.write("<p>"The inventory quantity is now " + newInventory + "</p>");
When placed after the variable, the Increment Operator doesn’t change the variable value until the next iteration. That means that it remains at a value of 100.
var onhandQuantity = 100;
var newInventory = onhandQuantity++;
document.write("<p>"The new inventory quantity is still " + newInventory + "</p>");

Decrement Operator
The Decrement Operator decreases the variable by an increment of 1 when placed before the variable. It’s denoted by two minus signs.
var onhandQuantity = 100;
var quantitySold = --onhandQuantity;
document.write("<p>"The inventory quantity is now " + quantitySold + "</p>");
When placed after the variable, the Decrement Operator doesn’t change the variable value until the next iteration. That means that it remains at a value of 100.
var onhandQuantity = 100;
var quantitySold = onhandQuantity--;
document.write("<p>"The new inventory quantity is still " + quantitySold + "</p>");

Negation Operator
This negation operator negates the value of the variable. It’s denoted by a single minus sign.
var onhandQuantity = 100;
var quantitySold = -onhandQuantity;
document.write("<p>"The inventory quantity is now " + quantitySold + "</p>");
When added to a variable with a negative value, the result is a positive value.
var onhandQuantity = -100;
var inventoryAdded = -onhandQuantity;
document.write("<p>"The inventory quantity is now " + inventoryAdded + "</p>");