In this lesson, we're going to talk about the if statement and all its many variations. And I've started us out with a simple if that is simply one condition, where if it's true, then the statement or statements inside this block will run. If it's not, then we just go right by and we keep going with whatever code comes later. Now notice what kind of a condition I've got here looks just like a variable. But in reality, that will be evaluated as a Boolean expression. So it will come out to be either true or false. Remember in JavaScript, anything with a value is true. So I can say powered on right there. And if powered on is the number six, or if it's a string with a few characters in it or something like that, then it will evaluate to true. If you want to be more sure about your condition and you'd like to remove the uncertainty, then you can say equals true or is greater than five or whatever works for you. The only values in JavaScript that will evaluate to false in that way that you see there would be zero, an empty string, something that was null, a variable that was undefined, or one that's n a n for not a number. So feel free to create as complex of a set of expressions as you want. Just know that the true falsiness will determine what runs or what doesn't run. So we have an if just there all by itself. Let's say I want to add some more conditions. I can have an else if and an else and by convention in JavaScript, we have the ending brace of the previous clause on the same line as the new clause. You don't have to. If you come from other languages, you might split things up on lines differently, no big deal. Do it however you like. Notice in my else if here, I have multiple conditions. So if it's powered on, but it's nighttime, then we're going to power this appliance on in quiet mode, so to speak. And then our else is our last condition. So again, one of these three is going to run because either this expression will be true or the second one or if neither of those are true, then we'll run our else clause. Keep in mind, this is what we call a first match kind of a statement. So the order that you put your conditions in matters because if this one is true, then those other conditions are never evaluated. Now you might have a situation where you're just doing something that looks more like this, just a plain if else. If that's the case, let me offer you a little way around that can make your code more compact. I can actually do this entire thing now with just this one line. And we call this a ternary expression because it has three parts. And if you wanted to do this in kind of pseudo code, you could think of it this way. So a variable gets assigned a value based on a condition. If the condition is true, we're going to assign what's in this position. If it's false, we're going to assign what's in that second position. So if all you're doing is an if else to do a single assignment to a variable, do consider the ternary expression to make more compact and more sophisticated looking code. In this lesson, we learned about the if statement and a way to even avoid the if statement if we want to make our code more compact. So thanks for watching. In the next lesson, we'll talk about the use of the switch statement as a conditional.