Is there any way to make this CoffeScript code simpler / smaller I've just started with coffeescript,  and I saw  http://blog.8thlight.com/uncle-bob/2012/04/20/Why-Is-Estimating-So-Hard.html  which has a little programming problem,  so I figured I'd do it in coffeescript (which seemed easy enough to do... )

anyways, I ended up with :-

lineEndings = ( s, len ) -&gt;
  words = s.split ' '
  line = ''
  result = ''
  words.map ( word ) -&gt;    
    if line.length == 0
      line = word
    else if line.length + 1 + word.length &lt;= len    
      line = line + ' ' + word
    else     
      result = result + line + '\n'
      line = word  
  result + line

getty = "Four score and seven years ago our fathers brought forth upon this continent a new nation, conceived in liberty and dedicated to the proposition that all men are created equal"  
console.log lineEndings getty, 13


I'm looking for any ways I could make this simpler coffeescript.

( I just used nodejs with coffescript installed to test this )
This is how I would write it.

lineEndings = (s, len) -&gt;
  words = s.split ' '
  line = []
  result = []
  for word in words
    if line.length + 1 + word.length &lt;= len
      line = [line..., word]
    else
      result.push line.join ' '
      line = [word]
  lastLine = line.join ' '
  result.push lastLine if lastLine
  result.join "\n"


There's nothing wrong with how you wrote it, though.