compare with jQuery
<p>I have an array called <code>billItems</code> in my jquery, and am having values in that like,</p>

<pre><code>[TUTION FEE ,SPORTS FEE ,CONVOCATION FEE ]
</code></pre>

<p>am iterating the <code>billItems</code> before adding new item, to avoid duplicate, like</p>

<pre><code>for (var i = 0; i &lt; billItems.length; i++) {
    var name = billItems[i];

    if (name == feesItem.ItemName) {  //here ItemName=TUTION FEE
        var validItem = 'False'
    }
}
</code></pre>

<p>as I mentioned above, am passing the <code>ItemName</code> as <code>TUTION FEE</code>, but its not comparing the strings and the control not comes into the block even its same. whats wrong with this query, can anyone help me here....</p>

<p>am just appending the datas into a html table like</p>

<pre><code>var feesItem = new Object();

  feesItem.ItemName     = $("#txtItemName").val();
  feesItem.Amount       = $("#txtAmount").val();

$("#BillTable &gt; tbody").find("tr:gt(0)").remove();
  for (var i = 0; i &lt; feesItemList.length; i++) {  
tab = "&lt;tr&gt;&lt;td&gt;" + " &lt;span class='bid'&gt;" + feesItem[i].ItemName + " &lt;/span&gt;
       &lt;/td&gt;&lt;td&gt;" + feesItem[i].Amount + "&lt;/td&gt;&lt;/tr&gt;";

          $("#BillTable &gt; tbody").append(tab);
}
</code></pre>

<p>its still not comparing the values...</p>

<p>I just tried comparing the values within the for loop like,</p>

<pre><code> var billItems = [];
  $(".bid").each(function () {
      billItems.push($(this).text());
  });

 var validItem = ($.inArray(feesItem[i].ItemName, billItems) &lt; 0);
</code></pre>
