# Arithmetic Operators in JavaScript

 SEARCH THIS SITE @import url(http://www.google.com/cse/api/branding.css); Custom Search

The use of arithmetic operators in Javascript explained through examples.

## Addition (+), Subtraction(-), Multiplication(*) and Division(/) in Javascript

The operators + , - , * and / are used to write arithmetic expressions as shown in the sample program below. Run the sample program below and check that the answer displayed is 0.

<!DOCTYPE html>
<html>
<body>
<script>
var x = 2, y = 3, z = 4, w;
w = 1.5 + y*(x - 4)/z;
</script>
</body>
</html>

## Modulo Operator in Javascript

The modulo operator written as % is used to find the remainder of the division of two numbers. Run the sample program below and check that the answer displayed is 3 which is the remainder of 27 divided by 4. (27 = 4 * 6 + 3)

<!DOCTYPE html>
<html>
<body>
<script>
var x = 27%4;
</script>
</body>
</html>

## Increment / Decrement Operator in Javascript

To increment a number x by 1 write it ++x. Run the sample program below and check that the answer displayed is 4.7 which is 3.7 + 1. To decrement a number by 1 write it - -x.

<!DOCTYPE html>
<html>
<body>
<script>
var x = 3.7;
var y = ++x;