Operators.
Hello, operator, are you there?
Hello, hello.
So I'm going to delete all the stuff that we have been reading, writing so far, if you've been writing
with me, you can delete all of your stuff or just comment it out and you can use it as a reference
for later.
In this lesson, we're going to talk about operators so operators are ways to work with variables so
we can say consed name is equal to Caillaux Torline.
And let pro fashion is equal to.
That's a programmer.
And I'm a programmer.
I'm also a teacher.
We might maybe overwrite this.
I'm not sure we want to make sure this is changeable.
But you know what?
My name is never going to change.
So I will always be Caleb Torline.
And so what we're doing here is we are using the assignment operator.
We're saying variable.
The constant name is equal to.
Caleb Torline, let the variable type profession that's the name is equal to this is a an assignment
operator, programmer and these are strings, this is a string and this is a string.
But there are lots of other ones as well, so let's go ahead and save this and let's just open up Google
Chrome and right.
Click inspect and let's go to our console and write some code in our console here.
It's going to make this just a tad bigger.
For anyone who's watching on their mobile devices and so let's go ahead and create a new variable,
let's say let.
Nothing is equal to 10.
None is equal to 10.
What if we wanted to add to it, we could say nothing is equal to NUM plus another 10 and this is going
to now be 20.
So now we're saying.
Hey, allocate a new piece of memory in our computer, use the current one, that's ten plus 10, and
this is going to give us 20, just like we see here, 20.
Go ahead.
We can clear this.
We can also say something like 10 plus 20 is going to give us 30.
This is the addition operator.
Now, some traction, very, very similar, we could do 23.
Minus 12 gives us 11 or we could say the total const.
No, let's do that because we might overwrite it total is equal to 23, minus 12.
Is 11 weeks now, we've stored that in a variable that we can overwrite down the road.
That's subtraction, we also have division.
Let's clear this out.
We also have division so we could do like 100 divided by ten is ten or ninety nine.
Divided by eleven is nine.
Or 99 divided by.
Eighty seven one point one three seven nine three one zero three four four eight two seven five eight
seven, obviously.
So that's division.
Let's go ahead and do multiplication, multiplication is nope, not that sign this one, your little
asterisk.
So we could do, let's say, three times three.
That's going to give us nine.
Now, those are the four basic math operators, we have a few more interesting ones in here.
We have exponents.
So three.
To the exponent of three is going to be three times three times three.
This is going to give us twenty seven.
We also have Modulus, a.k.a. remainder, so when you divide by a number and there's a remainder, what
does that going to be?
So when we do 10.
Divided by three, what is that women are going to be.
So it was three, six nine.
So it goes in three times with a remainder of one.
Ten modulus three gives us a remainder of one.
There's also two more I want to go over increment and decrement, so what do we currently have assigned
total?
Total is 11 and we could say total plus plus.
And what this is going to do is give us the exact same value, but what it actually did was it returned
11 and it said when you're done returning 11, add one more to it.
Total is now 12.
We can do the opposite.
We can say.
Plus plus total and instead of this.
Returning the current number is going to add to the number and then return it.
So now we're saying 12 is now 13 and this again will be 13 all the way versus total plus plus.
Again, this is going to say 13, but if we access it once more, it becomes 14.
So that is increment by one we use plus plus.
Now, if we want to do the same thing, but opposite, same, same, but different to a total total
of 14, we can say total minus, minus.
And that's going to give us, again, 14, but if we do.
Total once more, what this did was say, hey, give us the current value and then minus one, so this
is now going to be 13 and this gets a little bit weird because if we do minus minus total.
The current value was thirteen.
It's now going to say 12, as we currently expect, and if we write it once more, it's going to stay
as well.
So it's just the order of operations that happens behind the scenes.
Honestly, you don't need to remember that too much at this point in time.
The big ones you're going to want to remember are.
Equals division, multiplication, addition, subtraction and occasionally modulus.
Maybe exponents as well, maybe these ones are not going to use too often, like you don't really need
to know them like a professional right now.
But I would say, remember, these ones you've got in this order equals that assignment.
Division, multiplication, addition, subtraction, modulus.
Exponents increment by one, decrement by one.
In the next lesson, let's talk about different types of variables, a.k.a. data structures, and this
is actually not very hard at all.
This is somewhat of a buzzword.
People like data structures.
It's all part of algorithms.
It's really just different data types.
Nothing fancy about it.
Don't get too excited.
It's just different types of variables.
We'll talk about these in the next lesson.