Is there any way to make this CoffeScript code simpler / smaller
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.