# JS Shortcuts

The *= can be used multiply itself. Works with all math operators.

`` EXAMPLE: x += y   is x = x + y``

These can be mixed like →

``````//  Setup the variables
x = 5;
y = 7;
z = 21

//  If you wrote this out long
//  form to make the calculations
//  and change the variables to
//  reflect, it would look like this:
z = z / 14;
y = y + z;
x = x * y;
// RESULT: 42.5
// 		 x = 42.5
//		 y = 8.5
//		 z = 1.5

// Reset the variables
x = 5;
y = 7;
z = 21

// Now a much less verbose
// syntax with the same result

x *= y += z /= 14

// RESULT: 42.5
// 		 x = 42.5
//		 y = 8.5
//		 z = 1.5
``````

Get the remainder after diving two number simply by using the modulus(remainder) operator % →

``````11 % 4 // Results in a remainder of 3
// 11 /4 = 2, SO 4 * 2 =8, WHICH IS 3 SHORT OF 11

100 % 8 // Results in a remainder of 4
// 100 /8 = 12, SO 8 * 12 = 96, WHICH IS 4 SHORT OF 100

17 % 12 // Results in a remainder of 5
// 17 /12 = 1, SO 12 * 1 = 12, WHICH IS 5 SHORT OF 17``````

To check for EVEN or ODD numbers by getting the remainder (above) to divide by 2. If it === 0 (no remainder). If so, it is even. →

`` 5 % 2     // Results in a remainder of 1, so it is odd``

Post-Increment: x++ happens after variable expressions are evaluated. →

``````x = 10;
y = x++	   // Adds one AFTER expressions are evaluated``````

Pre-Increment: ++x happens before variable expressions are evaluated. →

``````a = 10;
b = ++b	   // Adds one BEFORE expressions are evaluated``````