Created
September 30, 2014 15:15
-
-
Save ethyde/7c3f03e99ce8309b9161 to your computer and use it in GitHub Desktop.
How to use javacript "for loop".
This file contains 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(start value; condition; increment){ | |
//code that will be executed over and over | |
} | |
// iterate 5 times use it for count loop | |
for(var i=0; i < 5; i++){ | |
console.log("The value of i is: " + i + " <br />"); | |
} | |
// increment by 2 instead of 1 | |
for(var i=0; i < array.length; i += 2){ | |
console.log(i + "<br />"); | |
} | |
// reverse incremente order | |
for(var i=10; i < 0; i--){ | |
console.log(i + "<br />"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment