Chapter 4: Using Variables in Math

428 12 1
                                    

Using variables in math is quite self-explanatory. A lot of times you will create another variable for your equation. (Or use an object, but that 's pretty far into the future).

var a = 12;
var b = 3;
var c = a + b;

This will make the variable 'c', have a value of 15! Now, this may confuse some people, so I will explain the other mathematical terms.

Multiplication: *
Division: /
Adding: +
Subtraction: -
To the power of: ^

JavaScript for NewbiesWhere stories live. Discover now