if-else definition made more clear to avoid confusion (#25449)

This commit is contained in:
Pratik Lodha
2018-12-20 17:00:51 +05:30
committed by Manish Giri
parent 03a576e7b1
commit 773aae4fdc

View File

@ -3,15 +3,15 @@ title: If-Else Statement
--- ---
## Introduction ## Introduction
The `if` statement executes a statement if a specified condition is `true`. If the condition is `false`, another statement can be executed using the `else` statement. The `if` statement executes a statement if a specified condition is `true`. If the condition is `false`, then the statement inside `else` block gets executed.
**Note:** The `else` statement is optional. **Note:** The `else` statement is optional.
```javascript ```javascript
if (condition) { if (condition) {
/* do something */ /* do this if condition is TRUE */
} else { } else {
/* do something else */ /* do this if condition is FALSE (or not TRUE) */
} }
``` ```