-
Notifications
You must be signed in to change notification settings - Fork 0
/
logical.js
47 lines (32 loc) · 1.21 KB
/
logical.js
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
// ! NOT Negates true to false and false to true
// const truthyValue = 'This is a truthy';
// let falseyValue = 0;
// console.log(Boolean(truthyValue)); //returns true
// console.log(!truthyValue); //returns a false
// console.log(Boolean(falseyValue)); //returns a false
// console.log(!falseyValue); //returns a truthy
// console.log(!!truthyValue) //RETURNS true
// console.log(!!!!!!falseyValue); //false
// && AND
// T && F = F
// F && T = F
// T && T = T
console.log(Boolean(0 && false)); //F
console.log(Boolean( 0 && true)); //F
console.log(Boolean(true && NaN)); // F
console.log(Boolean(true && !1)); // F
console.log(Boolean(!0 && "This is a string")); // T
console.log(Boolean( !0 && " ")); //T
console.log(Boolean(!0 && !!" ")); // T
console.log(false && "anything");// F
// || OR
// T || F = T
// F || T = T
// T || T = T
// console.log(Boolean( true || false));
;
console.log(Boolean(0 || false)); // F
console.log(Boolean(true || false)); //T
console.log(Boolean(true || 1)); //T
console.log(Boolean(!true || !false)); // T
console.log(Boolean(!1 || !0)); // T