Page 83 - PortGPT_V2.1_C8_Flipbook
P. 83
</SCRIPT>
</BODY>
</HTML>
On running the above program, we get the following output:
The if…else Statement
The if…else statement checks for a condition. If the condition evaluates to True, the indented block
following the if statement is executed, otherwise the indented block after the else statement is
executed. The syntax of the if… else statement is given below:
Syntax:
if (condition)
{
// When the condition is true then block of code to be executed.
}
else
{
// When ’if’ statement condition is false then block of code to be
executed.
}
Conditional Statements in JavaScript 81

