All right welcome back everybody.
I'm just going to go ahead.
I'm going to put this back in here.
It's pretty simple and I'm going to go get rid of that function right here in this a Tauriel.
I want to show you something called an if statement here.
OK.
And an if statement.
All it does is it checks to see if something is true.
So for example if I were to say you know if if you were to imagine your house in the heat if the heat
isn't on then it's going to be cool.
That's what an if statement is though and if the heat is on it's going to be warm so it checks for condition
and it has an action as a result.
So usually you need some kind of variable and obviously set up a global variable and I'll call this
variable we can call this variable number or cool numbers like that.
Right.
And we'll make it equal to 1.
Right so I will initialiser.
All right so we.
So we have a cool number.
Now what I can do here is if I put in an IF statement on his statement looks looks like.
Is this all we got.
If cool number now by the way what I'm about to show you.
I could spend an hour talking about I'm going to put double equals to one.
OK.
And you need it curly bracket again.
OK.
And when you put all this in the curly bracket here.
So if cool number is equal to one then it's going to execute this code.
And if cool number doesn't equal one that it won't execute the code.
So you can imagine that if we type in something here like this fun it still works.
But watch this.
If I change cool number two and I type in fun guess what.
It doesn't work because cool number is not equal to 1.
And so this code doesn't get get executed.
OK so I'm just going to go ahead I'm going to just actually close the H T.M. here and let's just take
a quick look at this.
Now another thing that J has been doesn't necessarily do but pretty much every other programming language
does this is they indent OK and I kind of does this here.
So I'm just going to go ahead I'm going to return this clearly brace just because it it makes a little
bit more sense to look at it like this.
Even though when I program I always put it like this because I know what I'm doing but to explain it
I'm going to go ahead and do this.
OK.
And you'll see that in here you can see that I'm just going to go ahead and Tab this out a bit and you
can see that the curly bridge brackets this clearly bracket looks like this.
OK.
And everything within this function this is what the block of the function is is what my highlighted
text here and everything within the if statement is what I've highlighted here.
So these curly brackets are super important because you need to section off blocks of code because of
it.
And we've already done that.
See that with a function but they also work for if statements k.
Now in some languages what will end up happening is that if you have a one line if statement.
So for example if I just type this and you have you know if cool number equals 1 or equals 2.
OK.
And then we can type in do something like this.
So sometimes you can get away with that but its best practices to always put in the curly brackets.
So you can see that this is the curly brackets here.
And the way it works is that as soon as you open up another curly bracket and you close it the closing
bracket is going to go to the last open curly bracket.
So this is a closing bracket goes up to last open.
Clearly bracket.
This is the last closing bracket is going to go up to the last curly bracket there.
OK.
So cool number is equal to 1.
It's going to do that and we equaled cool number as you will to do.
OK.
Simple enough and let's make sure this works.
One more time I'm just going to type in the word fun.
And there we go.
That's all it is.
OK.
So that is an if statement.
I'll see you guys in next tutorial.