Created
August 28, 2015 11:49
-
-
Save chuck0523/aed7821fb2b808a07a09 to your computer and use it in GitHub Desktop.
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
# array | |
for color in ["red", "blue", "pink"] | |
console.log color | |
# 1行で書くとこんな感じ | |
console.log color for color in ["red", "blue", "pink"] | |
# whenで条件指定 | |
console.log color for color in ["red", "blue", | |
"pink"] when color isnt "blue" | |
# "red" "pink" | |
# indexを取る | |
console.log "#{i} : #{color}" for color , i in ["red", "blue", "pink"] | |
### | |
0 : red | |
1 : blue | |
2 : pink | |
### | |
# object | |
result = | |
chuck : 50 | |
man : 20 | |
Hello : 40 | |
for name, score of result | |
console.log "#{name} : #{score}" | |
### | |
chuck : 50 | |
man : 20 | |
Hello : 40 | |
### | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment