Logical Operators

Logical operators combine or change boolean values.

OperatorMeaning
&&and
`
!not

And / Or

const temp = 20
 
if (temp > 0 && temp <= 30) {
  console.log("The weather is good")
}
 
if (temp <= 0 || temp > 30) {
  console.log("The weather is bad")
}

Not

const isSunny = true
 
if (!isSunny) {
  console.log("It is cloudy")
} else {
  console.log("It is sunny")
}