Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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