0 day streak
javascript / beginner
Snippet

The Logical OR Operator

The logical OR operator (||) returns true if at least one of the conditions is true.

snippet.js
javascript
1
2
3
4
5
const isWeekend = true;
const isHoliday = false;
if (isWeekend || isHoliday) {
console.log('Relax!');
}
nodejs
Breakdown
1
if (isWeekend || isHoliday) {
Checks if either isWeekend is true OR isHoliday is true.
2
console.log('Relax!');
This line runs because the first condition (isWeekend) is true.