js and operator code example
Example 1: or operator in javascript
var a = true;
var b = false;
if(a || b) {
}
Example 2: javascript and operator
const x = 7;
const y = 4;
(x == 7 && y == 5);
(x == 3 && y == 4);
(x == 7 && y == 4);
if (condition == value && condition == otherValue) {
return something;
}
Example 3: javascript and
var hungry=true;
var slow=true;
var anxious=true;
if(hungry && slow && anxious){
var cause="weed";
}
Example 4: or operator javascript
var a = 2;
var b = 5;
var c = 10;
if (a === 3 || a === 2) {
console.log("TRUE");
} else {console.log("FALSE");}
if (a === 4 || b === 3 || c === 11) {
console.log("TRUE");
} else {console.log("FALSE");}
if (b === 5 || c != 10) {
console.log("TRUE");
} else {console.log("FALSE");}
Example 5: less than equal to in javascript
| <= | less than or equal to | x <= 8 | true |
Example 6: and javascript
let a = 1;
let b = -1;
if (a > 0 & b > 0){
console.log("and");
} else if (a > 0 || b > 0){
console.log("or");
}