Monday, 19 August 2013

javascript loop array get counts

javascript loop array get counts

If I have an array like this how can I loop through and push the counts
into a a new array?
All help wlcomed!
var Products = [
['Product A'],
['Product A'],
['Product A'],
['Product A'],
['Product A'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Product B'],
['Old Product B'],
['Old Product B'],
['Old Product B'],
['Old Product B'],
['Old Product B'],
['Old Product]
];
End Goal :
var UniqueProducts = [
['Product A',5],
['Product B',6],
['Old Product B',9]
];

No comments:

Post a Comment