5.5.1 If…else Statements
If…else statement performs an indicated action only when the condition n evaluates to true; otherwise that action is skipped. The if…else selection statement allows you to specify that a different action is to be performed when the condition is true than when the condition is false.
Syntax
If (condition) { Code to be executed if condition is true } else { code to be executed if condition is not true }
× Forgetting one or both of the braces that delimit a block can lead to syntax error or logic error
<html> <body> <script type = “text/ javascript”> Marks = 60; If (marks>60) { Document.write (“you have passed!”); } else { Document.write (“you failed”); } </script> </body> </html>
Comments RSS Feed
Leave a Reply