From the course: JavaScript Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Logical operators

Logical operators - JavaScript Tutorial

From the course: JavaScript Essential Training

Start my 1-month free trial

Logical operators

- [Instructor] Conditional statements like this if, else statements rely on logical operators. We briefly talked about these earlier and now we can see them in action. A conditional statement is looking for a condition to either be met or not met, meaning we can use any expression that returns either true or false as the condition. In this example, I'm using the backpack age method which returns the number of days since the backpack was originally acquired and then I'm asking if the everyday backpack age is larger than or equal to 30, then we return backpack is used, otherwise we return backpack is new meaning the backpack is really under 30 days old. This is a good example of how conditional statements work. I can now change those to say, backpack age must be less than or equal to 30. Then of course I would have to change the logic here to say backpack is new at the top and then backpack is old at the bottom. If I want…

Contents