Skip to content

Instantly share code, notes, and snippets.

@cheng470
Created October 10, 2014 01:07
Show Gist options
  • Save cheng470/75b44051c8b1cd663e7c to your computer and use it in GitHub Desktop.
Save cheng470/75b44051c8b1cd663e7c to your computer and use it in GitHub Desktop.
判断是否是奇数,学习函数定义
odd = (num) ->
unless typeof num is 'number'
throw "#{num} is not a number"
unless num is Math.round num
throw "#{num} is not an integer"
unless num > 0
throw "#{num} is not positive"
num % 2 is 1
test = (v) ->
try
console.log odd(v)
catch e
console.log e
test "3"
test 3.7
test -3
test 3
@wzy0216
Copy link

wzy0216 commented Oct 10, 2014

3

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