• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7. Conditionals > The else Statement

7.2. The else Statement

With a lone if statement, we can cause a single code block to be optionally executed. By adding an else clause, we can choose which of two code blocks should be executed. Syntactically, an else statement is an extension of an if statement:

if (condition) {
  substatements1
} else {
  substatements2
}


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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