title: javascript loops rating
body: <p>i'm trying to loop 5 time html code and inside this loop trying to add color variable only number of the rating times.</p>
  
  <p>maybe another loop after html?<br/><br/>
  please give an idea maybe there is other better way todo this<br/><br/></p>
  
  <pre><code>Template7.registerHelper('rating', function(options) {
      var rating = this.avgrating;
      var color = 'color-orange'; 
      var html ="";
      for (i = 0; i &lt; 5; i++) {
          html += '&lt;i class="fa fa-star ' + color + '"&gt;&lt;/i&gt;';
      }
      return html;
  });
  </code></pre>
  
  <p>i m assuming var rating value 3 return html should return like this</p>
  
  <pre><code> &lt;i class="fa fa-star color-orange"&gt;&lt;/i&gt;
   &lt;i class="fa fa-star color-orange"&gt;&lt;/i&gt;
   &lt;i class="fa fa-star color-orange"&gt;&lt;/i&gt;
   &lt;i class="fa fa-star"&gt;&lt;/i&gt;
   &lt;i class="fa fa-star"&gt;&lt;/i&gt;
  </code></pre>