Skip to content

Instantly share code, notes, and snippets.

@dustintheweb
Created August 28, 2013 11:22
Show Gist options
  • Save dustintheweb/6364993 to your computer and use it in GitHub Desktop.
Save dustintheweb/6364993 to your computer and use it in GitHub Desktop.
various examples of for loops & syntax
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