# Mathematics in JavaScript3.6

Including mathematics within a program is a simple task. JavaScript makes it easy to create a mathematical expression. This part of the tutorial will describe how to create a mathematical expression and evaluate it.

## Mathematics in JavaScript

The following code sample shows how to store a Number value in a variable:

JavaScript
```var x = 10;
var y = 12;
```

Variables are not completely necessary in a mathematical expression, but for each of these examples they will be used to store the inputs and the outputs.

With these two variables, two numbers have been stored. For each of the following code samples these variables will be used.

## Mathematical operations

This is a list of all of the mathematical operations that can be carried out in JavaScript as well as examples of them.

The addition operator is the `+` symbol:

JavaScript
```var x = 10;
var y = 12;
var z = x + y;
```

Subtraction uses the `-` symbol:

JavaScript
```var x = 10;
var y = 12;
var z = x - y;
```

### Multiplication and division

Multiplication in JavaScript uses the asterisk symbol `*`:

JavaScript
```var x = 10;
var y = 12;
var z = x * y;
```

And division uses the forward slash `/` symbol:

JavaScript
```var x = 10;
var y = 12;
var z = x / y;
```

### Modular arithmetic

A final mathematical operator known as modulus performs a less well-known operation. What modulus does is it divides two numbers and returns the remainer of those two numbers. Take 10 and 12, if 12 is divided by 10 it leaves a remainder of 2:

JavaScript
```var x = 10;
var y = 12;
var z = y % x;
```

### Increment and decrement

The final mathematical operation that this page discusses is the increment and decrement operations. Incrementing means increasing in steps whereas decrementing means decreasing in steps.

The increment operator is `++`. In the following example the value will increment after each alert. This is called post incrementing:

JavaScript
```var x = 10;
```

The next example will show the value being increased before each alert. This is called pre incrementing:

JavaScript
```var x = 10;
```

Decrement is the same except that the symbol changes to `--`. The following is an example of post decrementing:

JavaScript
```var x = 10;
```

The following is an example of pre decrementing:

JavaScript
```var x = 10;
```

All of these examples increase or decrease by just one. To increase or decrease a value by another number, for instance 3, a different symbol is used:

JavaScript
```var x = 10;

x += 3;

//Subtract and Assignment
x -= 3;

//Multiply and Assignment
x *= 3;