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

Chapter 7. Conditionals > The else if Statement

7.3. The else if Statement

Using if and else, we can optionally execute one of two code blocks. By using if and else if, we can optionally execute one (or even none) of an unlimited number of code blocks. Like else, else if is a syntactic extension of an if statement:

if (condition1) {
  substatements1
} else if (condition2) {
  substatements2
} else if (condition3) {
  substatements3
} else {
  substatements4  // Catchall if other conditions were not met
}


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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