One of the examples that we used in the loop exercises gives us an opportunity to talk about some additional assignment operators that are available in JavaScript. Let me jump to that example that I'm referring to. So we did a for loop, where we took this sentence, and then we reversed it. So it was written backwards. And we did that by looping through the entire all the characters in the sentence and placing them in a backward variable. And then concatenating, what is currently in that variable to the next character.
So we'd start with the exclamation point, then without E, then C, and so on. There is a shorthand way to do what we have done in this statement here. And that's an that's another type of assignment operator. the equal sign is an assignment operator that we've used thus far, we've used it quite a bit. But there are some additional assignment operators. Let me show you another way we could have done this.
I'm going to put the variable in, and then I'm going to type plus equal and then sentence dot char at I. This line right here, does exactly the same thing as this line right here. It's just a shorthand way to do this part of it on the right side of the assignment operator. The plus equal says we want to include what is in this, but we also want to add what's on the right hand side. Okay, just to show you how that works. Let me go ahead and comment this out.
Copy the file path. Then let's take a look at it, open the console. As you can see it has reversed that sentence as well. All right, now while I'm in the console, let me open that up. I'm going to show you a few other assignment operators are like that. So I'm going to create a variable num is equal to five and num two is equal to 10.
Okay, we did the plus equal. Here it is, again, that should produce produce 15, right, because it's taking what's in on the left hand side of the assignment operator, and it's adding it to what's on the right hand side of the operator and then putting them in the variable that's on the left hand side. Let's do num two minus equal num. Two minus five. So num two which is on the left hand side of the operator is 10. Now don't let this confuse you too much.
Remember we've changed the value of num num is now 15. So 10 minus equal to 15 gives a negative five. All right, so now just so we know what the variables currently are numbers 15 and num two is minus five. Okay. I'm going to change num to well first before I do that, let's do num. Another assignment operator multiply equal num to the negative 75.
All right, so now num equals negative 75. All right, one more I want to show you First let me set num equal to 10 and num two equal to num. Divide equal number two. That's another one. So we're taking 10, dividing it by two, placing it in num. So once again, this operator will take the value on the left hand side of the assignment operator, do the mathematical operator to whatever's on the right hand side of the operator and then place the resulting value in the variable it's on the left hand side of the operator.
Really quick, let's jump back. And let's just review those additional assignment operators which I introduced. So plus equal Here is the format for plus equal, and that is the equivalent to num equals num plus num two, okay? minus equal right here should be a semi colon there. And that's the equivalent to num equals num minus num to the next one multiplication. You can see the equivalent see their division, the division assignment operator.
There is also a modular assignment operator. To be honest, I've never used this one, but I want to make sure you're aware of it. So those are some additional assignment operators that can be used to help shorten JavaScript statements. Which one you choose to use is really up to you. But you should be aware of them because you will see them in other people's code. All right, moving on.