File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed
Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change 1- // && -> logical and
2- // || -> logical or
3- // ! -> logical not
1+ // Logical Operators in JavaScript
42
5- let isLoggedin = true ;
6- let ispaid = false ;
3+ /*
4+ && Logical AND
5+ || Logical OR
6+ ! Logical NOT
7+ */
78
8- console . log ( isLoggedin && ispaid ) ;
9+ // Logical AND (&&)
10+ // Returns true if both conditions are true.
11+ console . log ( true && true ) ; // Output: true
12+ console . log ( true && false ) ; // Output: false
913
14+ // Logical OR (||)
15+ // Returns true if at least one condition is true.
16+ console . log ( true || false ) ; // Output: true
17+ console . log ( false || false ) ; // Output: false
1018
11- let isEmailuser = true ;
12- let isGoogleuser = false ;
13-
14- console . log ( isEmailuser || isGoogleuser ) ;
19+ // Logical NOT (!)
20+ // Inverts the boolean value.
21+ console . log ( ! true ) ; // Output: false
22+ console . log ( ! false ) ; // Output: true
You can’t perform that action at this time.
0 commit comments