title: Javascript word count cut off
body: <p>I have a div with an ID "shortblogpost". I would like to count up to 27th word then stop and add "..." at the end.</p>
  
  <p>I was trying the following code. Problem, Its counting letters and not words. I think its using jQuery and not strait up JavaScript?</p>
  
  <p>I need to use JavaScript for various server reasons only</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var limit        = 100,
      text         = $('div.shortblogpost').text().split(/\s+/),
      word,
      letter_count = 0,
      trunc        = '',
      i            = 0;
  
  while (i &lt; text.length &amp;&amp; letter_count &lt; limit) {
    word         = text[i++];
    trunc       += word+' ';
    letter_count = trunc.length-1;
  
  }
  
  trunc = $.trim(trunc)+'...';
  console.log(trunc);
  &lt;/script&gt;
  </code></pre>
  
  <p>Ty all in advance for any help.</p>