Skip to content

Commit 62e4810

Browse files
committed
Merge pull request GitbookIO#61 from sarthakmunshi/patch-2
Updated Logical Comparison
2 parents 1763d84 + ee9ad92 commit 62e4810

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

conditional/comparators.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Other conditional test:
1515
* ```x > a```: is x bigger than a?
1616
* ```x < a```: is x less than a?
1717
* ```x <= a```: is x less than or equal to a?
18+
* ```x >=a```: is x greater than or equal to a?
1819
* ```x != a```: is x not a?
1920
* ```x```: does x exist?
2021

@@ -44,3 +45,10 @@ assert(a === 10);
4445
```
4546

4647
---
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.

0 commit comments

Comments
 (0)