Created
February 12, 2012 20:33
-
-
Save k2052/1810744 to your computer and use it in GitHub Desktop.
For loops in coffeescript. Be careful how you port your code.
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
# This will never end because i++ wont be reached more than three times. | |
i = 0 | |
i = 0 | |
while i <= 10 | |
continue if i is 3 | |
console.log "The number is " + i | |
console.log "\n" | |
i++ |
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
# This will simply skip when i = 3 as intended | |
i = 0 | |
i = 0 | |
while i <= 10 | |
if i is 3 | |
i++ | |
continue | |
console.log "The number is " + i | |
console.log "\n" | |
i++ |
showell
commented
Feb 12, 2012
This is the JS.
var i;
for (i = 0; i <= 10; i++) {
if (i === 3) continue;
console.log("The number is " + i);
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment