• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

The if Statement

As we’ve already seen, the if statement enables you to execute a series of statements if a test condition is true. The if statement also includes an optional else clause that holds code to be executed if the test condition was false. Here’s what the syntax of this statement looks like, formally speaking—note that the code to execute is between curly braces, { and }:

if (condition) { 
    statements1 
} 
[else { 
    statements2 
}] 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint