In this lesson, we're going to be looking at operators and what we can do with operators in JavaScript.
So let's go back into our app, G.S., and we'll take a closer look at some of the things that we can
do with the operators.
So we already saw that we can assign a value using just the one equal sign to a variable.
So we're using let's score equals zero.
And that's how we're assigning a value to score.
I'm going to just clear this and we're going to reset some values for X, for Y, and we'll take a look
at the different operators that are available in JavaScript and we're going to look at a few other operators.
So first of all, we're going to assign a value to X and assign a value of five for X.
And then also let's assign a value for Y and Y can be equal to 10.
So we've got options for the.
Assignment values, so if we want to assign a value for ZET and take the value of X plus why we can
do that as well.
So this can be X plus Y and then what's console log the value of Z.
Save that and we'll just put it into the terminal so that returns back a value of 15 for X plus why
we also saw it that I'm going to just update this and we'll comment this out in JavaScript and then
we're going to do Y plus plus.
And we saw this in the last lesson that what happens here is that we end up with the value of Y plus
one.
So this is equivalent and this is just a shorthand method for adding Y so we can do the same thing as
if we were doing Y equals Y plus one.
So this is going to be equivalent to the Y plus plus statement.
And when we run the code, see that we get the same result that this is 11.
There's also a few other ones that we can assign values.
So if we want to assign a value of Y equals Y plus X. So if we want to do something like that and there's
also a shorthand method for that one.
So when we say that and run it, we end up with the value of 15 because we've got Y equals Y, so the
value of Y is ten, X is five.
So this is the equivalent of saying Y equals ten plus five.
We can also use a shorthand for this so we can remove out the Y equals Y and we can just do plus equals
X..
So what do you think the value of this is going to be?
Let's run it again in the terminal and we end up with 15 because this is the same thing as Y equals
Y plus X, so it's just a shorthand method for writing it.
We can also do the same for subtraction.
So if we want to do Y equals Y minus X, that's going to be the shorthand for that.
We can also do a multiplication shorthand, so Y equals Y times X. So that one is going to return back
50.
So five times ten fifty.
There's also a division assignment operator.
So that's going to be equal to Y equals Y divided by.
I'll give you a few more examples by name and how the JavaScript engine transfers from one to type to
also do the math on your statement.
The remainder due to the percentage sign.
So this is the same thing as doing Y equals Y and percentage sine X..
So what do you think the value of this is going to be?
And we know that we don't have any remainder here when we've got Y.
X divided into why we have no remainder, because we can do it two times nice and neatly, but if we
change Y to 11, what do you think the value is going to be for the remainder?
And if you said one, you are correct.
So try it out within your own editor.
And coming up next, we're going to look at Truthy and falsey and this is going to be important part
of setting conditions within your applications.