title: Jquery- How to remove comma after a specific record in an array
body: <p>I am using the datatables <code>mRender</code> function to generate a list of items in a column separated by commas. I wanted to remove a specific record from the list and the record lies at the end of list of records in an array. Something like this:</p>
  
  <pre><code>LESS,SAAS,REST,API
  </code></pre>
  
  <p>I want to remove the last record (API, which i did), however, when i remove it the comma still sticks to it at the end, resulting into something like:</p>
  
  <pre><code>LESS,SAAS,REST,
  LESS,SAAS,
  </code></pre>
  
  <p>assuming that all time the record after the comma is the <code>ALL</code>. How can i remove the record and also the comma that sticks after it??
  EDIT: This is how i have the code and im removing the <code>API</code>, by passing empty string. Please suggest of this could be done better.</p>
  
  <pre><code>mRender: function (obj) {
      _.each(obj, function(item, index){
          var prodVal = "";
  
          else if (item === 'API'){
              prodVal = '';
          }
  
          returnVal.push("&lt;span class='product'&gt;" + prodVal + "&lt;/span&gt;");
      });
  
      return returnVal.join(', ');
  }
  </code></pre>
  
  <p>Any ideas???</p>
  
  <p>Thanks!</p>