While Loop

The while loop iterates until the condition becomes false.

var n = 5;

Text1.text = "The factorial of " + n;

var fact = 1;

 

// -- Compute n!, where n is a non-negative integer

while (n > 1) {

  fact = fact * n;

  n = n -1;

}

 

Text1.text += " is " + fact;

The break command can be used inside any loop to terminate the loop and 'continue' can be used to skip to the next iteration.

<< For Loop © 1996-2013 InetSoft Technology Corporation (v11.4) Switch Statement >>