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
if(calcaverage(x,y,z) < 10)
document.write("The average is less than 10.");
document.write("The average is 10 or more.");
You shouldn't use simple assignment statements such as if(a = b)
in a conditional statement.