The easiest way to check multiple conditions is by using logical operators like &&
(AND) or ||
(OR).
Example using &&
(AND):
let x = 5, y = 10;
if (x > 0 && y > 5) {
console.log('Both conditions are true');
}
Example using ||
(OR):
let x = 5, y = 2;
if (x > 0 || y > 5) {
console.log('At least one condition is true');
}
Tags: basic, JavaScript, Conditionals