If statement with else : if « Statement « Flash / Flex / ActionScript






If statement with else

 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){


        var animalName:String = "turtle";
        
        if (animalName == "turtle") {
          trace("Yay! 'Turtle' is the correct answer.");
        }
        else {
          trace("Sorry, you got the question wrong.");  
        }
    }
  }
}

        








Related examples in the same category

1.If Statements
2.Performing Actions Conditionally
3.If Statement with boolean constant
4.An if statement with no else
5.Chaining if statements
6.Performing Complex Conditional Testing