Welcome to another part where we are going to do, if else statement, so if else statement are one
of the most important, blocking every programming languages, including JavaScript.
So if condition is met, we're going to do some actions or else something else.
That is what is if our statement.
So what we're going to do, I'm just going to close everything here and I'm going to create here.
I'm going to copy it.
I'm going to say rename if else HTML and.
Sorry about those guys, give us the means and I'm just going to copy this here and I'm going to put
it on top and I don't need this, actually.
Why do you copy it, if else?
So I haven't created JavaScript file and then I'm going to create and now if else, I just know this,
if else that Jarius, let just load it up here forward slash if else the HTML.
Very good.
So why is giving mekouar.
Oh yeah.
Because I haven't saved it now.
That's good.
So how are we declaring it else.
So if else statements.
So in order to do this we're going to create a couple of variables here.
I'm going to say variables working.
So is working
position or work position in need?
So Naem will be.
Yeah, we can use double quotes or whatever you want, rig work position.
Let's put it here as a web developer here is working.
He's working.
We're going to put it is working only like that.
Now you can put a yes or no.
Doesn't matter.
So the condition if it's like this starts with if statement in these brackets.
Now inside here, we're going to type the condition.
Now, if it's working equal to these means, that is identical to know, for example, which is not
the case in inside this currently break brackets, that is our block F block where we are putting we
can put a couple of lines here or we can put the rest of the code or our logic.
So should what I'm doing here, I'm checking if this variable then holds the string is having this no
inside.
But working is not equal to no.
So it's not going to go there.
So is I'm going to say causal log in the C rig not working.
Right.
And if I refresh it, if you go inspect it, in comes a lot.
You will not be able to see anything because this condition is not met.
That's why we have ls block in our block.
We don't have conditions like this.
Right.
But what we do have here is because we do have the option to do the opposite of this one.
So we know that it's not if it's not going to go there, this block, it's not going to be executed.
Maybe you're going to have a couple of lines here, like five, six, seven lines that do some calculation
or whatever it is.
Now, we know that this is not going to if this is not going to do if this is not true, it's going
to go in Elstein, you can say else.
Yes.
And you could see like this name.
Oops.
So what I'm doing here, I actually don't know.
Yep.
Supports the video because I need to turn on the light.
So plus and we're going to do it here, we're going to say yes, Rick is working in actually here.
You need space a little bit.
Yes.
Rick is actually working in space and we're going to put here in this position and you're going to put
space here and to say work position now, because this condition is not me, it will go straight here.
And we if you have more and more lines underneath, it will go there and it will get executed.
So, yeah, rig is working and that is a position as a position developer.
Now, it doesn't have to be.
This here is working like that.
It can be true or false.
For example, let's put it false here.
Oh, let's put it true.
Now let's change a little bit now it can be a boolean values, so we just overwrite the value that it
holds.
So now it's boolean value.
So I'm going to copy this part just to make it more.
So now we're not going to check against anything.
We're just going to pass in the variable here.
So if this is return, true break.
So we need to swap this.
Actually, because our logic is different now, yes, Rick is working in the position they're in this
one, Rick is not working right.
So that is pretty much it now.
Yes, Rick is working as a developer and this one is coming from number 19.
Here it is, number 19.
OK, let's change it.
Um, we're going to make a two and we're going to make it one here.
And so you will not you will be able to one, the rig is working in this position.
The developer.
Yes, Rick.
Is working in this position.
Web developer.
OK, so if we change this to first look at how quickly this an EF five, if you press EF five, you
don't have to refresh.
Rick is not working, right.
Means that I don't work anymore.
And that's pretty much it.
So that is how we can use.
But this is very simple.
We will use a lot more complex.
But if else statement is the statement that you need to know.
So if else else, if there is a lot of different statements that we can cover in the future.
But this is the starting point.
And I want you to know what if else statement means it.
If this condition is met, this block is run.
If not, then this this block is going to be run.
That's pretty much it.
Same in BHP, same in every in C++, JavaScript, Java's everywhere.
The same logic is there.
Right.
Thank you very much.
And I will see you in the next.