Removing the last two instances of a character
<p>I'm building a string based on selected checkboxes. I wrote a statement that will add pluralization if there are multiple strings selected, but I cannot figure out how to remove the last two commas that are put into the 'policyHidden' field by the array.</p>

<pre><code>$(document).ready(function(){
    $('input:checkbox').change(function() {

      var keys = [];

      var policies = $('input:checkbox:checked').map(function () {
        return $(this).siblings('span').text(); }).get();

      $.each(policies, function(key, value) { keys.push(value) });

      output = keys.join(", ");

      FormSetFieldValue('policyHidden', output);

      if (keys.length &gt; 1) {
        keys.splice(keys.length - 1, 0, "and");
      }

      FormSetFieldValue('policyHidden', output);

    });
});
</code></pre>

<p>example output is</p>

<pre><code>value1, value2, and, value3
</code></pre>

<p>I just want to remove the last two commas. should I do a regex?</p>

<p><em>FYI, FormSetFieldValue is a function from another script; first variable calls the variable wanting to be changed, second one is the set value. Shouldn't have any consequence on the problem at hand.</em></p>
