title: jquery array checkbox repeating index value how to get rid of it
body: <p>jquery array each function repeating last index value how to get rid of it. please help.</p>
  
  <p><strong>jquery</strong></p>
  
  <pre><code>var addToCheckbox = function () {
        var newNames = new Array();
      $("input[name='skills']:checked").each(function ()
      {
          newNames.push(this.value);
          $("input[name='skills']:checked").prop('checked',false)
    nestableList.append('&lt;li&gt;'+newNames+'&lt;/li&gt;');
  
    });
  };
  
       $("#menu-checkbox").submit(function (e) {
          e.preventDefault();
          addToCheckbox();
        });
  </code></pre>
  
  <p><strong>Html</strong></p>
  
  <p><H2>Multiple Checkbox Select/Deselect - DEMO</H2></p>
  
  <pre><code>&lt;form class="" id="menu-checkbox"&gt;
         &lt;input type="checkbox" name="skills" value="JavaScript" /&gt;JavaScript
          &lt;input type="checkbox" name="skills" value="jQuery" /&gt;jQuery
          &lt;input type="checkbox" name="skills" value="C#" /&gt;C#
          &lt;input type="checkbox" name="skills" value="VB" /&gt;VB
          &lt;br /&gt;&lt;br /&gt;
          &lt;button class="btn btn-info" id="addButton"&gt;Add&lt;/button&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p><strong>result:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/kA7u2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kA7u2.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/so6Mc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/so6Mc.png" alt="enter image description here"></a></p>