categorizing data in in to hash map
<p>I have a javascript object in the following format and I am trying to categorize it</p>

<pre><code>var inputFacetArray=[
  { category:
"Company"
,  name:
"nokia"
},  { category:
"Persons"
,  name:
"ben affleck"
},  { category:
"Persons"
,  name:
"daniel craig"
},  { category:
"Persons"
,  name:
"george clooney"
}]
</code></pre>

<p>I am trying to get it in to the output format</p>

<pre><code>[{Persons:["george clooney", "daniel craig", "ben affleck"]}, {company:["nokia"]}]
</code></pre>

<p>My code is following</p>

<pre><code>var facetCategorizedArray=[];
for(var k=0; k&lt;inputFacetArray.length; k++){
    var l={};
    inputFacetArray[k]["name"].push(l[inputFacetArray[k].category]);
    facetCategorizedArray.push(l);
}
</code></pre>

<p>above code is not working.</p>
