title: Limit amount of records displayed in javascript or jquery .each loop to html
body: <p>I want to limit the amount of data in my javascript .each loop to only 5 records</p>
  
  <p>This works but certainly seems like OLD SCHOOL Hack...</p>
  
  <pre><code>var count = 0;
  
          $.each(allData, function (index, news) {
  
              if (count &gt;= 5) {
                  return false;
  
              } else {
                  var dateString = news.created;
                  var date = new Date(dateString);
                  var formattedDateString = (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear().toString().substr(2, 2);
  
                  strResult += "&lt;li&gt;&lt;ul&gt;" + formattedDateString + " : &lt;a target='_parent' href='http://" + dochomenotlocal + "/doc-home/#/tips/2?paginatePage=1'&gt;" + news.title + "&lt;/a&gt; By: " + news.createdby + "&lt;/ul&gt;&lt;/li&gt;";
  
                  count++;
              }
  
          });
  </code></pre>