More operators to come in this lesson, and they are important.
So we are going to spend a little bit more time on operators.
So we saw not operators.
And there's also increment, which is a shorthand method for operators.
And we could also update our assignment operators by using the plus equal sign instead of just the equals
sign equal plus.
And I'm going to show you some examples of these coming up.
So we saw it with assignment operators where we could set a variable, we could declare a variable and
we can sign a value using that equal sign.
So there's a little bit more we can do as well.
And Mozilla has a great and Mozilla has a document on this, of course, for the assignment operator.
So there's the equal sign.
So we are familiar with that one.
And we're also looking at how we can equal it.
And then we can have another formula here.
So another arithmetic or operator there, and they've got the full list of different types of assignment
operators.
So we've got addition, assignment, subtraction, assignment, multiplication, division and so on.
There's a whole bunch of operators that are available for you.
So the typical assignment operator is just the equal sign.
But we can also equal and equal so that all of them will equal that one value.
So X, Y and Z are all going to be equivalent to the same value because then at the end is equal to
25.
There's also a shorthand, which is the plus equal sign.
So this is equivalent to X equals X plus Y, or you could do X plus equal Y.
So that's a shorthand format for doing that.
And they've got some examples here of those.
And we can also do a number plus a string.
And this is just concatenation.
So JavaScript takes care of the data type X equals X minus wire.
We could do X minus equal Y, so it's the same thing and some additional examples of that.
And of course we can't subtract strings as we saw before.
So that's where we get that nine again.
So nine not a number.
There's also multiplication, same format and also division where we can do the assignment division
and shorten that as well.
And that will definitely keep you busy trying out all of those examples.
So we did see that we did have a shorthand method and we also have the ability to increment.
So plus plus, minus minus.
And that's equal to X equals X plus one or X equals X minus one, comma B comma C comedy.
But we can also assign values as we're declaring them and we can assign multiple values at one time
to variables.
So now we have an interesting challenge for you in this lesson and that's to take the code and determine
what the output of the code will be.
So what's going to be output in the console?
So try out some of the different operators, try out some of the different combinations and see what
you can get as the solution to this code number is going to be equal to five.
Second number is going to be equal to ten variable A equals five plus five.
We're going to see that A has a value of ten, of course.
And now if we take A and if we equal it to a plus ten, then that's going to return back the value of
eight at twenty.
Or we could do a and plus equals another ten.
And what do you think the value of A is going to be?
If you said thirty, you are correct.
So do try that out and play around with it a little bit.
Let's finish up this.
So we saw that we can do these different assignment values and we can also increment eight.
So now if we return back a we get a value of thirty one and notice that the response is still at thirty
because we're responding back to the value of a so we haven't done the increment quite yet.
And that's the same thing.
If we do a minus minus we're still at thirty one.
But when we look at the value of a it's thirty, so keep that in mind that we're always seen that as
the response.
So if we were actually assigning a value of whatever a minus minus is equal to, we would still be holding
that initial value before we did the actual subtraction and we're going to increment it by one and then
take the second number and we're going to decrease it by one and then we're going to create another
variable and assigning a value of first num plus second num, and that's going to be the value of total
and first of all, console logout, whatever the value of total is.
And we're going to equal that to five hundred plus one hundred divided by five plus total.
So also let's logout the value of total and you can see that we're being returned back fifteen for the
first one.
So what's happening here is that first number is five second numbers, ten.
We're adding one to first number, so.
Getting back six and then we're subtracting one from second number, so we're getting six plus nine,
and that's leaving our total of 15.
So if you take those in first number, we've got six second number, we've got nine.
And that's where we get in the 15.
The next one, 500 plus one hundred divided by five plus total.
So one hundred divided by five is twenty five hundred plus twenty plus the value of total.
And we know the value of total is 15, then we get a total of 335.
So that's how we can work out the calculations for this particular assignment.