Website Development Online Courses

# Arithmetic Operators in JavaScript

The standard Arithmetic operators are as follows:

OperatorsDescription
Subtraction-
Multiplication*
Division/
Modulus%
Increment++
Decrement--

Let see Example of each

```<script type="text/javascript>
var x = 5;
var y = 3;
var result = x + y;
document.write("Final Result is " + result);
</script>
```

The answer will be 8 which is 5 + 3

Subtracion

```<script type="text/javascript>
var x = 5;
var y = 3;
var result = x - y;
document.write("Final Result is " + result);
</script>
```

The answer will be 2 which is 5 – 3

Multiplication

```<script type="text/javascript>
var x = 5;
var y = 3;
var result = x * y;
document.write("Final Result is " + result);
</script>
```

The answer will be 15 which is 5 * 3

Division

```<script type="text/javascript>
var x = 5;
var y = 3;
var result = x / y;
document.write("Final Result is " + result);
</script>
```

The answer will be 1.6666666 which is 5 / 3

Modulus

```<script type="text/javascript>
var x = 5;
var y = 3;
var result = x % y;
document.write("Final Result is " + result);
</script>
```

The answer will be 2 which is 5 % 3. It will show the remainder

Increment

```<script type="text/javascript>
var x = 5;
var y = 3;
var result = x + y;
result++
document.write("Final Result is " + result);
</script>
```

The answer will be 9. It will increment 8 by 1

Decrement

```<script type="text/javascript>
var x = 5;
var y = 3;
var result = x + y;
result--
document.write("Final Result is " + result);
</script>
```

The answer will be 7. It will decrement 8 by 1