What's up, guys?
Welcome to another lecture here, are we going to learn about a logical operators and arithmetical operators
like math operators that we can use here in JavaScript, like plus minus division in times and also
greater and than there are called logical operators.
So they're not only basic arithmetic operations that we can do, we can do something even more powerful
and logical.
For that reason, I just don't want to continue here working.
So what I want to do, I'm just going to copy this index and I'm going to name it and I'm going to say
operators, operators, not HTML.
I'm just going to close this one.
I mean, cut that one.
And I really don't need all of these.
So to make sure that you need rename it to operators, the HDMI, save it now I'm just want to create
an additional JS file called operators.
That genius is that operators of genius will be linked here.
Sorry, yeah, oops, operators are just so script.
Yes, we don't need it anymore, and now we can work with this one and we can just see, OK, operators,
JavaScript, fundamental, logical and math operators.
Maybe we should do the same thing for each and every one, but it doesn't matter now.
We are here and we can do a couple of things here.
And what I want you to do is I would like to jump a little bit in future.
So I'm going to create some function here because I don't know when you're going to see this lecture,
maybe in future, like a year or two years from now.
And I don't want to be boring in 2020 here.
And you can see in 2022 over there.
Right.
So I'm just going to use the date function, word date, and that will be cool.
New date.
Don't worry about this.
We're going to cover it in future in our current year.
That would be equal.
They don't get full year.
So if I do a lot now, current year you chewed, um, but now you need to be careful because these Geass
increase hooked up with index that.
So even even if I do index that e-mail, I would actually see the same page.
But now in order to see the operators, I need to go slash operators.
Not very good now.
So JavaScript fundamentals and here it is the year is there 2020.
Now, why I did this because I'm going to do something
like maybe I'm going to do subtraction, division and stuff like that.
So what I'm going to do here after this, I'm going to say create a variable and I will say result.
Next year, oh, so I have coming here, I will resolve next year and into future.
Just these are just variables, guys, don't worry about it, it's nothing, not nothing connected with
JavaScript the way it's named right now.
So actually, I'm going to put this one.
Here comes a lot.
And what else?
So here for the result, I want to see even I want to create this date of birth.
Delpy So my date of birth, it will be for example or it's going to be yours so will be it will for
example nineteen ninety five.
That's not the year that I'm born by the way.
So what we can do is math operator minus.
So what we can do here is I'm going to see a result.
It will be current year minus the date of birth.
So I'm doing this coming year is always going to be greater than date of birth.
So I don't want to put them date of birth minus current year because I'm going to have minus value and
I don't want to have that one right.
Because it's not the logic for us.
So 1995 minus twenty twenty.
How much it will be twenty five years.
Nice.
So if we change this one to nineteen eighty seven the year that I'm born it's going to be thirty three
years.
God I'm old, I'm old.
So that will be minus operator and we can just leave this one here like that.
I'm just going to copy it and I'm going to put it here.
It's going to be C plus operator in here.
I'm going to say next year I'm going to see one right.
Next year will be current year plus next year.
Or you can just put one here.
Ian, I just want to print the result.
So this is the mutation, remember?
So we just used the same variable here, but we placing a different result, different calculation.
So let's see, 2021 perfect.
You can even see like this next year it will be eight plus.
Next year it will be twenty, twenty one.
OK, and here I am sorry.
So when you want to put quotations like this, I'm just going to say so double quotes and you can say
I am.
I'm thirty three because you don't want to use two single quotes.
You need to put double quotes inside this here.
So I'm thirty three.
Very good.
Current year this year is sorry, semicolon.
And I'm going to say a plus here.
Leave it a little bit.
Space this year is twenty twenty.
How cool is this.
Should we have done math.
Plus minus plus minus plus.
Right.
Yeah we're going to do times and let's say let's create here like variable three PWCS three and say
here a three is going to be actually three.
In result will be courrier times.
Three.
So here it will be multiplication.
Multiplication is I should give me something like really bigger numbers, 60, 60, right.
So you don't have to use Kering.
You know, if this is not working for some for some reason in future, you can just hardcoded were current
here and put it twenty.
Twenty or your current year, 2021.
2022 doesn't matter.
When are you going to see it.
I'm just going to in because we don't need to use it.
Right.
Because we use this date function.
Very good.
So now you know how to.
OK, we need to do a division as well now.
Division and yeah, we're going to divide it by three and let's say the result is going to be six,
seven, three, that so he's going to be decimal number.
How cool is that?
This is actually very good.
And it's working.
No, we know how to use all of these operators, but how about logical operators?
OK, now the next part is.
Logical operators so they can be greater or smaller then, but now we're going to have, um, were first.
And I'm going to have second in, first I will put for the first, I will put like 10 years.
Second, I will just initialize it to back to what the let's say 15.
Oh, no, let's say five.
Know what we can do.
We can just check.
We can just check if the first number is greater than the second number.
So I'm going to create an additional variable here called is bigger is smaller now they are not initialized.
So is bigger equal first greater than the second.
Now if I do cancel log, I'm just going to copy this one because council is bigger, because I want
to know what, what, what value I'm printing.
It's not going to be a result.
I'm just going to print.
This is bigger now.
What, you think ten is bigger than five.
What you think is going to be true.
So the logical operator will always return true or false so they can return a number because we are
comparing ten is bigger than five.
OK, now I'm just going to put an additional line here and say is smaller.
So first is it um, let's say is first smaller.
The the second one what you think what will happen.
So if Wheelock is smaller and we need to put it here is smaller size.
Just copy control.
See, don't worry about it.
Now that will return false because actually ten is bigger than the second one.
So that is how you can use logical operators.
Now, one more thing.
What we can do is we can just because I want to finish this with operators saying after that we're going
to deal with something else, we can just check the type of operators.
So what is this?
We can just check, for example, I'm just going to copy Consul Log and I'm going to check.
So in order to check that off, you need to actually type off.
So that will check.
Look what will happen type of Ismailis.
So we're checking this variable here.
Now, this here, it will give me a boolean value because that is what it is.
Actually, it's true or false.
It's Boolean values.
Very good.
Now, if I go back here, if I go here and if I check first.
If I check what else we do have, OK, I'm going to create another here string, I'm just going to name
a string or name just to put a name here, and I'm going to say name Rick and let's put it out.
So we have first I have name.
So for the first I should expect integer for the second type of I should expect to be string in for
this one is we already checked.
That is Boolean.
So no, as I told you, integer or no string and boolean.
Now you know also how you can check the types of operators.
So before we are doing something else, for example, see this was something that I have done when I
was like when I was starting like 15, 20 years ago, when I was starting with Web development in in
actually in school.
Right.
In high school.
So we had a we have a subject called programming or web development in there is something like here.
So we can create a variable called a first number and we can have a second number.
But at that time was super interesting because we wanted to ask the user to be prompt in into enter
the values.
So how we can do this.
So do you know how we can do this now?
This is very interesting that because we can prompt the user, for example, where I don't need actually
so first number is equal to prompt.
OK, and here I will ask I will ask the user, enter the first number and let's see what's happened.
So this prompt will actually give me something like this so I can cancel it, by the way.
But what if give me an option to enter five and if I hit enter that number five will be stored in this
variable here.
You're not going to be able to see it because I'm not printing anywhere.
So here I'm going to say second number, enter the second number in the console.
OK, so what are we going to do is actually I'm just going to put a result here.
I'm going to use the same one result equal first number plus second.
No, very good end result.
I'm just going to lock the result.
So what I'm going to do, I'm going to say twenty plus ten.
The first number will be twenty and the second number will be ten.
You know, one here to have the result is a thirty 2010.
OK, we're not just doing that one.
OK, just.
Now, what is happening is that we are just grabbing and JavaScript is thinking that we do have only
two Selex or 20 in 10, it considered them.
And that's why you me in 2010, because we just concatenate them and consider them as a string.
So maybe that was not a good example.
Maybe should enter the first name or the second name.
Now we are getting a lot of a if we want to do if we want to actually grab the real value, we can do
pass Barzman.
So because remember, they can be floats that can be integer and we can pass them the string as and
convert it into a float or integer.
So I'm going to say pass.
Float.
And there's a function, so I'm just.
I mean, I'm going ahead fast float again.
That's not good.
Maybe I should stick it to the and I think with capital F should be right, not with this one float.
Now, I expect them this string of 20 to be considered as a number and the result will be 30.
So first float will pass in.
But you should not be worried about this party at this stage.
But this is not in this stage.
So I'm going to get 35 plus 15.
That should give me 50.
Right.
That's it.
Now, I'm just going to comment this one and I'm just going to copy it.
And actually, I'm going to copy that.
I'm going to come this one as well.
You know why?
Because we're going to changes because at this stage, we should not do.
This is the first.
Just going to copy this first name.
It's better like this first name and last name, now
first name, enter your name, your name, and the second the last name will be here.
And let's put it like this last name.
Enter your last name.
Now, the concatenation or the result will just work fine when we put.
Because these are considered as what?
As the strings.
So sorry about this one.
So we just went in like ahead of time.
So enter your first name and OK, the second name will be Cyclosporine and Hideaki.
So I don't have a space here, which we should have because it looks bizarre.
Just going to copy it again.
So I'm going to say.
Rick.
Yeah.
And I'm going to hear OK, now I do have this space, OK, this lecture is going crazy.
So we learn about operators like a logical operators these days ahead of time.
If you don't if it's not working for some reason for you, just use this one.
So plus division multiplication minus everything is working.
It also logical approach is greater or smaller than in.
We can check their type o it also we can prompt the user to tell us instore those those what the user
is grabbing from here actually because here this is the input form we are grabbing here.
We are storing in the first name after that when we doing from the last name we are storing in the last.
Right.
So thank you very much.
I hope you enjoyed least like share, subscribe and enjoy.