STATEMENT:  if...else


if (condition) {statements1} [else {statements2}]
 
The if...else statement executes one set of statements if a specified condition is true, and another if it is false.
 
The following example tests the result of a function and displays one of two messages depending on whether the result is less than 10 or not:
 
Code:
if(calcaverage(x,y,z) < 10)
   document.write("The average is less than 10.");
else
   document.write("The average is 10 or more.");

 
NOTE:
 
You shouldn't use simple assignment statements such as if(a = b) in a conditional statement.


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information