Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created August 23, 2015 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/8bd412fc360d1cdd68e8 to your computer and use it in GitHub Desktop.
Save chuck0523/8bd412fc360d1cdd68e8 to your computer and use it in GitHub Desktop.
# if
score = 80
# 基本形
if score > 60
console.log score
# 1行で書く
if score > 60 then console.log score
# 条件文の後置
console.log score if score > 60
# JS書いてきた人にはわかりやすい書き方
if score > 60
console.log 'ok'
else
console.log 'ng'
# elseも含めて1行で書いちゃう
if score > 60 then console.log 'ok' else 'ng'
# coffeeでは三項演算子は使えない
# condition ? a : b ;
msg = if score > 60 then 'ok' else 'ng'
console.log msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment