GeezerVison is showing github.com — Updated Logical Comparison · FarajDEV/javascript-2@ee9ad92
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: conditional/comparators.md +8Lines changed: 8 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -15,6 +15,7 @@ Other conditional test: |
15 | 15 | * ```x > a```: is x bigger than a? |
16 | 16 | * ```x < a```: is x less than a? |
17 | 17 | * ```x <= a```: is x less than or equal to a? |
| 18 | +* ```x >=a```: is x greater than or equal to a? |
18 | 19 | * ```x != a```: is x not a? |
19 | 20 | * ```x```: does x exist? |
20 | 21 |
|
@@ -44,3 +45,10 @@ assert(a === 10); |
44 | 45 | ``` |
45 | 46 |
|
46 | 47 | --- |
| 48 | +##Logical Comparison |
| 49 | + In order to avoid the if-else hassle, simple logical comparisons can be utilised. |
| 50 | + |
| 51 | +```js |
| 52 | +var topper = (marks > 85) ? "YES" : "NO"; |
| 53 | +``` |
| 54 | +In the above example, `?` is a logical operator. The code says that if the value of marks is greater than 85 i.e. `marks > 85` , then `topper = YES` ; otherwise `topper = NO` . Basically, if the comparison condition proves true, the first argument is accessed and if the comparison condition is false , the second argument is accessed. |