coffee to one orange

coffee script to a single div

by Andy Bulka

HTML

<h1>Welcome to my coffeescript fiddle</h1>
<h2>output:</h2>
<div id="out"></div>

CSS

div#out {
  background-color: #FAD3A9;
  font-size: 1.2em;
  margin:12px;
  padding:4px;
}
h1              { font-size: 2em; margin-left: .67em 0 }
h2              { font-size: 1.5em; margin-left: .75em 0 }
h3              { font-size: 1.17em; margin: .83em 0 }

CoffeeScript

pr = (msg, crlf=true) ->
  $('#out').append msg
  $('#out').append ' ' if not crlf
  $('#out').append '<br>' if crlf
  
pr(num, crlf=false) for num in [50..1]  
pr('<hr>')
  
###
class A
  constructor: (name) ->
    @name = name+'s'
  pr: ->
    @name+='z'
    @name+'Z'

square = (x) -> 
  z = x * x
  z2 = "hi"
  100

a = new A('fred')
alert(a.pr())
alert(square(10))
###