Skip to content

Instantly share code, notes, and snippets.

@cardoni
Last active August 29, 2015 14:15
Show Gist options
  • Save cardoni/2fcbdfb982e6e935f7cd to your computer and use it in GitHub Desktop.
Save cardoni/2fcbdfb982e6e935f7cd to your computer and use it in GitHub Desktop.
es6 let
'use strict'
for( let x = 0; x < 1; x += 1 ) {
for( let x = 0; x < 20; x += 1 ) {
console.log( 'inside: ', x );
}
console.log( 'outside: ', x );
}
@dyoder
Copy link

dyoder commented Feb 13, 2015

CS would be:

do (i = 0) ->
  while i < 1
    do (i = 0) ->
      while i < 20
        console.log "inside: #{i++}"
    console.log "outside: #{i++}"

@dyoder
Copy link

dyoder commented Feb 13, 2015

For loop version, which looks weird because the first loop only has one iteration:

do (i = 0) ->
  for i in [0]
    do (i = 0) ->
      for i in [0..19]
        console.log "inside: #{i}"
    console.log "outside: #{i}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment