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//|| is the or operator in JavaScript
2if(a == 1 || b != 'value'){
3 yourFunction();
4}
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
1const num = 6;
2if (num <= 4 || num <= 8) {
3 console.log('true')
4} else {
5 console.log('false')
6}
7//Expected output:true
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
1/*OR operator:*/
2||
3
4// example:
5var a = 10;
6var b = 5;
7
8if(a > 7 or b > 7){
9 print("This will print!")
10}
11// Even though a is not less than 7, b is, so the program will print
12// the statement.