-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbooleans.html
More file actions
75 lines (61 loc) · 1.94 KB
/
booleans.html
File metadata and controls
75 lines (61 loc) · 1.94 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
<!DOCTYPE html>
<html>
<head>
<title>Booleans</title>
</head>
<body>
<script>
/*
console.log(3 > 5);
console.log(5 == "5.00"); //coversion behaviour
console.log(5 === "5.00"); //no conversion behaviour
console.log(5 != "5.00"); //conversion behaviour
console.log(6 !== "6.00"); //no conversion behaviour
const age = 17;
if(age >= 18)
{
console.log("You can drive");
}
else
{
console.log("You can not drive");
}
*/
/*
if(5)
{
console.log('Truthy');
}
if(0)
{
console.log('Falsey');
}
const cartQuantity = 5;
if(cartQuantity)
{
console.log('Cart has products');
}
console.log(!0); //true
console.log('text' / 5); // NaN
let unVariable;
const variableUndefined = undefined;
console.log(unVariable); //undefined
*/
const result = true ? 'truthy' : 'falsy';
console.log(result);
const result = 0 ? 'truthy' : 'falsy';
console.log(result);
const result = 5 > 6 ? 'truthy' : 'falsy';
console.log(result);
false && console.log('Hello'); //when we use && like this, its called the guard operator
const message = false && 'hello';
console.log(message); //false
const message = 5 && 'hello'; //using the OR operator to set a deffault value
console.log(message); //hello
const currency = 'EUR' || 'USD';
console.log(currency); //EUR
const currency = undefined || 'USD';
console.log(currency); //USD
</script>
</body>
</html>