Change Language


Follow Navioo On Twitter

if...else

If the expressionA is true, executes statementA. If the expression is false, evaluates expressionB. If expressionB is true, executes statementB. Otherwise, executes statementC.

Syntax

if (expressionA)
   statementA
[else if (expressionB)
   statementB]
 [else
   statementC] 

Example

if (myCat=="Jasmine")
   alert (myCat);
else if (myCat==" ")
   alert("No cat!");
else
   alert("Wrong cat!");  

Remarks

You can nest as many "else if" statements within the block as you need; however, if you use multiple "else if" statements, you might want to consider using a "switch" statement for cleaner code.

text_javascript Navioo_docs

Examples -> Source code Demo online - > else statement:

Ajax Javascript feed

↑ Grab this Headline Animator