1var a = 2;
2var b = 5;
3var c = 10;
4
5if (a === 3 || a === 2) {
6 console.log("TRUE");
7} else {console.log("FALSE");}
8if (a === 4 || b === 3 || c === 11) {
9 console.log("TRUE");
10} else {console.log("FALSE");}
11if (b === 5 || c != 10) {
12 console.log("TRUE");
13} else {console.log("FALSE");}
14
15/* Output:
16TRUE
17FALSE
18TRUE
19*/
1// === means equal value and equal type
2var x = 5
3
4// true
5x === 5
6
7// false
8x === "5"
1//OR Operator
2
3const x = 7;
4const y = 4;
5
6(x == 5 || y == 5); // false
7(x == 7 || y == 0); // true
8(x == 0 || y == 4); // true
9(x == 7 || y == 4); // true
10
1//&& returns true if both values are true
2//or returns the second argument if the first is true
3var a = true
4var b = ""
5var c = 1
6
7true && "" //""
8"" && 1 //""
9false && 5 //false
1const num = 6;
2if (num <= 7 && num <= 8) {
3 console.log('true')
4} else {
5 console.log('false')
6}
7//Expected output:true
1var x = 5;
2
3// === equal value and equal type
4// e.g. 1.
5x === 5 returns true
6
7// e.g. 2.
8x === "5" returns false
9
10// !== not equal value or not equal type
11// e.g. 1.
12x !== 5 returns false
13
14// e.g. 2.
15x !== "5" returns true
16
17// e.g. 3.
18x !== 8 returns true