You can apply mathematic operations to numbers using some basic operators like:
- Addition:
c = a + b
- Subtraction:
c = a - b
- Multiplication:
c = a * b
- Division:
c = a / b
You can use parentheses just like in math to separate and group expressions: c = (a / b) + d
Create a variable x
equal to the sum of a
and b
divided by c
and finally multiplied by d
.
var a = 2034547;
var b = 1.567;
var c = 6758.768;
var d = 45084;
var x =
var a = 2034547;
var b = 1.567;
var c = 6758.768;
var d = 45084;
var x = ((a + b) / c) * d;
assert(x === (((a + b) / c) * d));