Unexpected Identifier in Javascript
<p>I am adding content to a list dynamically and I want to be able to prevent adding duplicates. So before content is added I am selecting all the list, make an array and check that the data I am adding is not already contained in the list. However I get a unexpected identifier in my code. This is my code:</p>

<pre><code>$(".autocomp_centers").autocomplete({
    var ids = new Array();
    $("#sister-centers-list &gt; li").each(function(index, value){
        ids.push($(value).attr('class'));
        console.log($(value).attr('class'));
    });

    serviceUrl:'/suggest_centers',
        maxHeight:400,
        width:252,
        params: {country: $("#country").val() },
        minChars:2,
        onSelect: function(value, data){
            if ($.inArray(data, ids) == -1){
                alert("Sister center has already been added.");
            }else{
                $("#hidden-ids").append('&lt;input type="hidden" name="center_ids[]" value="' + data +'" class="center-' + data + '"/&gt;');
                $('#sister-centers-list').append('&lt;li class="center-' + data + '"&gt;' + value + ' &lt;a href="#sister-center" class="remove-center-before-save" id="' + data + '"&gt;Remove&lt;/a&gt;&lt;/li&gt;');
            }               
            $("#sister-search").val("");
        }
});
</code></pre>

<p>When the person starts typing and this method is called, I get the list values and store them in an array. When they select a value, I check if the value is already in the array. This is the line that causes the error: <code>var ids = new Array();</code></p>
