Incrementing is adding 1, while decrementing is subtracting 1.
Incrementing and decrementing is a somewhat difficult concept, so take a deep breath and relax. We have a standard document.write method happening. In that method, we have a string that is showing you which variable we are talking about. So, the "w++ = " is a string and not a variable. Then, we add that string to the w++ variable that is being incremented. (Quick Note: Strings can be combined with integers using the +, however, if you were to try to combine two integers in this manner, it would give you the sum of them.) The important part here is the order of the increment or decrement operator. Notice how incrementing the w, as in w++, gives you the result of 0, but incrementing the y, as in ++y, gives you the result of 1. This is because it is an increment operator has two options. Since the increment operator is after the w, as in w++, it needs incremented after the statement has been performed, while ++y is incremented before the statement is performed, since the ++ is before the y.
Let's try to clear up that String + integer part really quick:
So, that is how you combine two strings.
These are not a necessity for programmers, but they are great shortcuts.
Your code will execute in this window.
Let's explore some more tutorials or topics!
Stephen D March 6, 2014, 3:05 p.m.What is supposed to happen when you insert the <h> tag when testing the code? I don't see anything happen.
Rafael Paiva July 16, 2013, 6:44 a.m.Very great content! Easy to understand the Operators. Congratulations for the method. I would like to appoint some mistakes in the example of "Assignment Operators". The result of calc's is different in the middle of exercise. I think that it is something wrong in "variable x". Thank's for this site! I'm happy to study here.