More operators and operations
JavaScript has more operators other than those stated earlier. Let's go little bit deeper.
Increment or decrement operators
If you have an integer and you want to increment it by 1 or any number, you can type the following:
var x = 4; // assigns 4 on the variable x. x = x + 1; /* since x=4, and you are adding 1 with x, so the final value is 4 + 1 = 5, and 5 is stored on the same variable x. */
You can also increment your variable by 1, typing the following:
var x = 4; // assigns 4 on the variable x. x++; // This is similar to x = x + 1.
What will you do if you want to increment your variable by more than 1? Well, you can follow this:
var x = 4; // assigns 4 on the variable x. x = x + 3; // Say, you want to increment x by ...
Get JavaScript Projects for Kids now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.