SpinSpire logo

Logical Operators

In JavaScript conditions can be combined using and/or logic.

OR

if(name === 'john' || name === 'jane') {
console.log('name was either john or jane');
}

AND

if(name === 'John' && age === 25) {
console.log('Both conditions are true')
} else {
consol.log('One or more of the conditions evaluated to false')
}

NOT

if(user.role !== 'admin') {
console.log('user does not have the admin role')
}