by
4,758 18
-1
4
988
2
Top 1% !
Popular
Tagged
Specified
Popularity: 33614th place
This snippet is Public
Languagejavascript
LicenseMIT_X11

for loop

a. A more efficient way to code to increment up by 1 is to write i++.
b. We decrement down by 1 by writing i--.
c. We can increment up by any value by writing i += x, where x is how much we want to increment up by. e.g., i += 3 counts up by 3s.
d. We can decrement down by any value by writing i -= x.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/395442/for-loop?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
// Example of a for loop: for (var counter = 1; counter < 11; counter++) { console.log(counter); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus