Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- choice = ['g','c','p']
- my = process.argv[2]
- enemy = (->
- choice[Math.floor(Math.random() * choice.length)]
- )()
- console.log "my: #{my}"
- console.log "enemy: #{enemy}"
- judge = (my,enemy) ->
- table = {g: "c" ,c: "p",p: "g"}
- if my in choice and enemy in choice
- switch enemy
- when table[my] then return "Win"
- when my then return "Draw"
- else
- return "Lose"
- else
- return "error"
- console.log judge(my,enemy)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement