Building and maintaining an options array/object in JavaScript
<p>I'm building a faceted/filtering search for a project I'm currently working on and I'm looking for a function (or jquery plugin) to help me do this. Let's say I have an object like the following:</p>

<pre><code>var options = {
    "country": 2,
    "Gender": 1
}
</code></pre>

<p>I then have a function called filter(). I pass filter the key and value of the option I want to toggle/add/update. My current function is causing me nothing but trouble and I'm too far down the debugging rabbit hole to make it worth posting. Essentially I have this:</p>

<pre><code>filter('country', 3);
</code></pre>

<p>would update the 'country' key to have '3' as its new value.</p>

<pre><code>filter('Age Group', 4);
</code></pre>

<p>would add that key/value pair to the options object.</p>

<pre><code>filter('Gender', 1);
</code></pre>

<p>would remove the 'Gender' key from the object completely.</p>

<p>Any point in the right direction would be appreciated.</p>
