title: javascript: limit number of items
body: <p>sorry but I'm new in javascrit.
  I'm writing a simple rss reader, but I want to limit the number of feeds to 5 items, because the my target site can have 100 or more.
  Here the code:</p>
  
  <pre><code>$("#mainPage").live("pageinit", function () {
      $("h1", this).text(title);
      $.get(RSS, {}, function (res, code) {
      var xml = $(res);
      var items = xml.find("item");
      var items = $items.length &amp;&amp; i &lt; 5; i++); // here the problem!!
      var entry = "";
              $.each(items, function (i, v) {
              entry = {
                   title:$(v).find("title").text(),
                   link:$(v).find("link").text(),
                   description:$.trim($(v).find("encoded").text()),
                   category:$.trim($(v).find("category").text()),
                   date:$(v).find("pubDate").text().substr(0,16),
                   autor:$(v).find("creator").text()
              };
               entries.push(entry);
           });
       var s = '';
       $.each(entries, function(i, v) {
          s += '&lt;li&gt;&lt;a href="#contentPage" class="contentLink" data-entryid="'+i+'"&gt;' + v.title + '&lt;br&gt;&lt;i&gt;' + v.autor + ' - ' + v.date + '&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;';
          });
          $("#linksList").append(s);
           $("#linksList").listview("refresh");
      });
  });
  </code></pre>
  
  <p>The problem is that when I try to limit the number of items adding 
      var items = $items.length &amp;&amp; i &lt; 5; i++);
  the javascript stop to works. :-(</p>
  
  <p>How to do it?</p>