The browser storage localStorage is not available. Either your browser does not support it or you have disabled it or the maximum memory size is exceeded. Without localStorage your solutions will not be stored.

# Numbers

Numbers are represented by simple numerals. They can have a decimal point and a minus sign.

`var x1 = 1;`

var x2 = 1.0;

var x3 = 3.14;

var x4 = -1;

`1`

and `1.0`

are the same number. You can calculate with numbers. The four basic arithmetics adding, subtracting, multiplying and dividing are represented by ` + - * `

and `/`

.`var x1 = 6;`

var x2 = 2;

var x3 = x1 + x2;

var x4 = x1 - x2;

var x5 = x1 * x2;

var x6 = x1 / x2;

The variables `x3`

to `x6`

thus have the values `8`

, `4`

, `12`

and `3`

.## Exercise

Write a function

`add`

that takes two numbers and returns their sum. `add(1, 2)`

should return `3`

.
+ Hint

```
var add = function(x, y) {
return ...
};
```

+ Solution

```
var add = function(x, y) {
return x + y;
};
```