title: jquery add / remove item from array
body: <p>I have a checkboxs 3-4 of them, when the user checks the checkbox I want to add the value of the checkbox to the array, if they uncheck the box I want to remove the item from the array, this is what I got so far:</p>
  
  <pre><code>$('ul.dropdown-menu input[type=checkbox]').each(function () {
      $(this).change(function () {
  
          if ($(this).attr("id") == 'price') {
              if (this.checked) {
                  priceArray.push($(this).val());
              }
              else {
                  priceArray = jQuery.grep(priceArray, function (value) {
                      return value != $(this).val();
                  });
              }
          }
      });
  });
  </code></pre>
  
  <p>Adding the value to the array works perfectly, however removing items results in this error:</p>
  
  <pre><code>Cannot read property 'toLowerCase' of undefined
  </code></pre>
  
  <p>on this line:</p>
  
  <pre><code>return value != $(this).val();
  </code></pre>