Ian R
0
Q:

or in javascript

//The OR operator in Javascript is 2 verticals lines: ||

//Example
var booleanOne = true;
var booleanTwo = false;

if(booleanOne || booleanTwo) {
	//At least one boolean is true -> code excuted
}
11
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");}

/* Output:
TRUE
FALSE
TRUE
*/
1
//|| is the or operator in JavaScript
if(a == 1 || b != 'value'){
    yourFunction();
}
1
//OR Operator 

const x = 7;
const y = 4;

(x == 5 || y == 5); // false 
(x == 7 || y == 0); // true
(x == 0 || y == 4); // true
(x == 7 || y == 4); // true
-1
//OR operator expressed as ||

const x = 7;
const y = 4;

(x == 5 || y == 5); // false 
(x == 7 || y == 0); // true
(x == 0 || y == 4); // true
(x == 7 || y == 4); // true

if (condition == value || condition == otherValue) {
  return something;
}
-1

New to Communities?

Join the community