in array

in array

hey guys im having a slight probelm with the in array function (obviously my fault)...but what im trying to do is if a category isnt in the count array then for it to be added to array with a value of 1.

if category exists in array increase value by 1.

here is my code which keps just running this line below even if in array

  1. count[item.category] = 1;

  1. var count = [];        
  2. // loop start
  3.         if ($.inArray(item.category, count) === -1){
                count[item.category] = 1;
            }
            else
            {
                count[item.category] = count[item.category] + 1;
            }
  4. // loop end

any help would be greatly appreciated...thank you