This is down to changes that were made for new versions of ZPE.
The following code sample shows how to store a Number value in a variable:
var x = 10; var y = 12;
Variables are not completely necessary in a mathematical expression, but for each of these examples they will be used to store the inputs and the outputs.
With these two variables, two numbers have been stored. For each of the following code samples these variables will be used.
The addition operator is the
var x = 10; var y = 12; var z = x + y; alert(z);
Subtraction uses the
var x = 10; var y = 12; var z = x - y; alert(z);
var x = 10; var y = 12; var z = x * y; alert(z);
And division uses the forward slash
var x = 10; var y = 12; var z = x / y; alert(z);
A final mathematical operator known as modulus performs a less well-known operation. What modulus does is it divides two numbers and returns the remainer of those two numbers. Take 10 and 12, if 12 is divided by 10 it leaves a remainder of 2:
var x = 10; var y = 12; var z = y % x; alert(z);
The final mathematical operation that this page discusses is the increment and decrement operations. Incrementing means increasing in steps whereas decrementing means decreasing in steps.
The increment operator is
++. In the following example the value will
increment after each alert. This is called post incrementing:
var x = 10; alert(x++); alert(x++);
The next example will show the value being increased before each alert. This is called pre incrementing:
var x = 10; alert(++x); alert(++x);
Decrement is the same except that the symbol changes to
--. The following is an example
of post decrementing:
var x = 10; alert(x--); alert(x--);
The following is an example of pre decrementing:
var x = 10; alert(--x); alert(--x);
All of these examples increase or decrease by just one. To increase or decrease a value by another number, for instance 3, a different symbol is used:
var x = 10; //Add and Assignment x += 3; alert(x); //Subtract and Assignment x -= 3; alert(x); //Multiply and Assignment x *= 3; alert(x); //Divide and Assignment x /= 3; alert(x);
As shown in the comments, this is called the operation and assignment, since what happens is the operation is carried out and then it is assigned to the variable.
Each of these operations are the equivalent to it's mathematical operation described previously.
S1s and S2s really enjoyed the lesson on cybercrime using the lesson on How to Rob A Bank on… https://t.co/MxjDYE2JFu
7 months ago
S2s doing really well in hardware test! Also really enjoying doing tests electronically rather than on paper.… https://t.co/ritdfcW6Mw
7 months ago
S1 and S2 pupils listing input and output devices and giving answers such as keyboard and mouse but there were also… https://t.co/dGxDkYqFxo
8 months ago