- The Object
- Intro to Variables
- Your first script
- Built-in functions alert function Contd
- Confirm boxes
- The Prompt Function
- The For Loop
- Arithmetic and Assignment Operators
- Reserved Words
- Members (7935)
- Member Articles ( 12 )
- Discussion (15)
- Q & A ( 9 )
- - Ask Question
- - Questions
- - Unanswered Questions
Lesson 12: Arithmetic Operators and Assignment Operators
7 Principal Arithmetic OPERATORS:
Arithmetic operators are used to do figure mathematical operations between variables and/or values. We are covering the most common ones here and the rest will be covered in the advanced tutorial. The seven main arithmetic operators are:
- + Addition: adds
- - Subtraction: subtracts
- * Multiplication: multiplies
- / Division: divides
- ++ Increment: increases by one
- -- Decrement: decreases by one
- % Modulus: divides and returns the remainder
6 Principal Assignment OPERATORS:
= Makes the preceding variable equal to the following value or variable.
+= Makes the preceding variable equal to itself plus the following value or variable.
Example: x+=y is the same as x=x+y
-= Makes the preceding variable equal to itself minus the following value or variable.
Example: x-=y is the same as x=x-y
*= Makes the preceding variable equal to itself multiplied by the following value or variable.
Example: x*=y is the same as x=x*y
/= Makes the preceding variable equal to itself divided by the following value or variable.
Example: x/=y is the same as x=x/y
%= Makes the preceding variable equal to the modulus of itself and the following value or variable.
Example: x%=y is the same as x=x%y
*Note: This lesson and the next are the only two that do not have accompanying code snippets because these two are mainly for reference. That’s why I made them the last two lessons, because they are where an appendix would normally go. I did not want to change the flow of the tutorial though, so I made them lessons as well.
Now go on to Lesson 14, Reserved Words: Yes, we skipped Lesson 13 out of silly superstition….
- - Google Chrome / Mozilla?
- - Delete text after focus c
- - Statistics
- - Select all values in te