-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06-booleans.html
More file actions
111 lines (83 loc) · 2.84 KB
/
06-booleans.html
File metadata and controls
111 lines (83 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8">
<title>Booleans</title>
</head>
<body>
<script>
/* console.log(typeof true);
//console.log(sizeof('true'));
console.log(3 < 5);
console.log(3 > 5);
console.log(3 != 5);
console.log(3 == 5);
console.log(5 =='5');// In java script if you compare with '==' then the lag convert both to same data type
console.log(5 ==='5');
//this works fine in js
//following the '!=' is not recommended '!==' is the best way comparing not equals to in the JS
console.log(5 !='5');
console.log(5 !=='5'); //comparative operators have lower priority in the operations
const age =15;
if(false)
{
console.log('hello');
}
else{
console.log('world');//else statement
}
if(age >=16)
{
console.log('Eligible to drive');
} else if(age >= 14)
{
console.log('Almost there to drive');
}
else{
console.log('Not Eligible to drive');
console.log('till your age');
}*/
/*console.log(true && true); //and operator if two conditions are true the it returns true
console.log(true && false);// here both are not true so it returns false
console.log( 0.2 >= 0 && 0.2 < 1/3);
console.log(Math.random());
console.log(true ||false);
console.log(false || true);// or operator in 2 statements if atleast on is true then it will return true
console.log(false || false);
console.log( !false);
console.log( !true); */
if(5)
{
console.log('Condition is true');/*truthy value because value inside iff consider as true */
}
let n;
if(NaN){console.log("false value");}
if(n){console.log("false value");}
if(false){console.log("false value");}
if(''){console.log("false value");}
if(NaN){console.log("false value");}
console.log(".");// considered as falsy value
//the following are false ,0 ,'',NaN, undefined,null.excluded the above falsy value remaining values are true.
//creating truthy and falsy values are to create the shot cut for the execution code.NaN ie; not a number.
let zero = 0;
if (!zero) {
console.log("Zero is falsy!"); // Might not be what you intended
}
const cQuantity=5;
if(cQuantity> 0) {
console.log("cart is not empty");
}
if(cQuantity) //works similar way than the above if statements
{
console.log("cart is not empty");
}
else if (cQuantity <1){
console.log("cart is empty");
}
console.log(!0);
const a='text'/5;
console.log(a); //NaN(Not a number)
let va;
console.log(va); //undefined
</script>
</body>
</html>