What does the ++ sign mean in this code:
for (var i=0; i < myString.length; i++) {
alert(myString[i]);
}
while (x>y) {
alert ("xrules!");
y++;
}
What does the ++ sign mean in this code:
for (var i=0; i < myString.length; i++) {
alert(myString[i]);
}
while (x>y) {
alert ("xrules!");
y++;
}
It's the increment operator. It's (almost) equivalent to saying i = i + 1
Note that the increment operator does not exist in python, you have to either write the whole thing out or use the add assignment operator i += 1
Note that there are post (i++
) and pre (++i
) increment operators, as well as equivalent decrement operators --i
i--
. These operators differ on when the increment is applied, and are often a cause of frustration for new programmers.