JavaScript Shortcuts

Shorten simple if statements

Instead of:

Do:

var myResult;
if (#var1==1) myResult=true;
else myResult=false;

var myResult = #var1==1 ? true : false;



Shorten assignment operators

Note: the following examples assume local variables, if using a StudyTRAX variable precede the variable code with a 3.

Operator

Shortcut

myCount = myCount + 1;

myCount++;

myCount = myCount - 1;

myCount--;

var1 = var1 + var2;

var1+=#var2;

var1 = var1 - var2;

var1-=#var2;

var1 = var1 * var2;

var1*=var2;

var1 = var1 / var2;

var1/=var2;