Mathematics is an important part of life that we can’t get very far without. This is particularly true when we are learning to program JavaScript. We do depend on processing numerical data, calculating new values, and so on, that we won’t be surprised to learn that JavaScript has a full-featured set of math functions available.

### Familiar Operators

We can use a math expression wherever we may use a number. For instance, we’re familiar with this kind of statement.

var popularNumber = 4; But we can also write this. var popularNumber = 2 + 2; we can also write: alert (2 + 2);

This displays the message “4” in an alert box.

JavaScript always does the math and delivers the result when it sees a math expression. Here’s a statement that subtracts 24 from 12, assigning -12 to the variable.

`var popularNumber = 12–24;`

This one assigns the product to the variable of 3 times 12, 36.

#javascript