# Javascript Performing Math

## Javascript Performing Math

When working with numeric values in JavaScript, you can perform mathematics with the numbers. Not only can you add, subtract, multiply, and divide
numbers, but you can also perform other advanced mathematical calculations.
The four basic mathematical operations are as follows:
•   Addition: For instance, 10 + 20
•   Subtraction: For instance, 20 – 10
•   Multiplication: For instance, 10 * 20
•   Division: For instance, 20 / 10
In addition, you can build complex mathematical expressions using combinations of these operations. For instance, the following expression subtracts 10 from the
result of 100 divided by 5:
100 / 5 – 10
You can override the order of operation with parentheses. Consider the following mathematical expression:
100 / (5 – 10)
This will calculate the value of 100 divided by the result of subtracting 10 from 5.
There are two important points to note about these sorts of mathematical expressions:
• You can use them wherever JavaScript expects a single numeric value. For instance, you can assign the results of an expression to a variable:
var myVariable = 100 / 5;
• You can use variables containing numeric values anywhere in your mathematical expressions in place of actual numbers. For instance, if thisVar is a variable with the value 5, then the results of the following JavaScript code are the same as the preceding example:
var myVariable = 100 / thisVar;
```<body>
<script language=”JavaScript”>
<!--
var myVariable = 100;
var anotherVariable = 200;
var finalResults = myVariable + anotherVariable;
document.write(finalResults);
// -->
</script>
</body>
```