Logical AND in JavaScript
You can group comparison operations using the
&& operator, which is a logical AND.
In the following example, if the variable
num is greater than zero and
simultaneously is less than 10,
only then '+++' will be displayed:
let num = 3;
if (num > 0 && num < 10) {
console.log('+++');
} else {
console.log('---');
}
Conditions can be imposed not on one variable,
but on different ones. In the following example,
if the variable num1 is equal to 2
and simultaneously the variable num2 is
equal to 3, only then the condition
will be true:
let num1 = 2;
let num2 = 3;
if (num1 == 2 && num2 == 3) {
console.log('+++');
} else {
console.log('---');
}
Check that the variable num is
greater than zero and less than 5.
Check that the variable num is
greater than or equal to 10 and
less than or equal to 20.
Check that the variable num1 is
equal to or less than 1 and the
variable num2 is greater than or
equal to 3.