Changes

Jump to: navigation, search

JavaScript Flow Control and Looping

336 bytes added, 14:23, 24 April 2007
The JavaScript ''if ... else'' Statements
As shown in the above example the script following the ''if'' statement is executed when the expression is evaluated to be true (i.e the customerName variable contains the string "Fred") and the script after the ''else'' statement is executed when the customerName does nmot match the string "Fred".
 
''if ... else'' structures can be taken a step further to implement ''if ... else ... if'' structures. For example:
 
if (customerName = "Fred")
{
document.write ("Hello Fred!");
}
else if (customerName = "John")
{
document.write ("Hello John!");
}
else
{
document.write ("You're not Fred! Where's Fred?");
}
</pre>
== JavaScript Looping Statements ==

Navigation menu