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

Chapter 6. Controlling Your Code I: Test... > Using if()…else to Handle a false Re...

Using if()…else to Handle a false Result

Using the if() statement to make decisions adds a powerful new weapon to your JavaScript arsenal. However, this technique suffers from an important drawback: A false result only bypasses one or more statements; it doesn't execute any of its own. This is fine in many cases, but there will be times when you need to run one group of statements if the condition returns true and a different group if the result is false. To handle this, you need to use an if()…else statement:

if (expression) {
   true statements
}
else {
   false Statements
}


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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