Created
August 28, 2013 11:22
-
-
Save dustintheweb/6364993 to your computer and use it in GitHub Desktop.
various examples of for loops & syntax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var i=1; i<26; i = i++) { // counting from 1 to 25 | |
console.log(i); | |
} | |
for (var i = 5; i < 51; i+=5) { // counting from 5 to 50 in increments of 5 | |
console.log(i); | |
} | |
for (var i=8; i<120; i+=12) { // counting from 8 to 119 in increments of 12 | |
console.log(i); | |
} | |
for(i=100; i>=1; i-=5){ // counting backwards from 100 to 0 in increments of 5 | |
console.log(i); | |
} | |
for (var i=10; i>=0; i--) { // counting backwards from 10 to 0 | |
console.log(i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment