How do I count the number duplicate fields in a non duplicate array?
<p>I have a (Messages) collection full of users with read and unread messages, similar to the one illustrated below:</p>

<pre><code>userName               READ MESSAGES     unreadMessages
Paul Otterson             1                0
Vincent Guily             0                1   
Paul Otterson             0                1
Vincent Guily             0                1 
Paul Otterson             1                0
</code></pre>

<p>I am able to eliminate "userName" duplicates, which I accomplish by this helper code:</p>

<pre><code>Template.messages.helpers({

'Names': function () {

var loggedUserName = Meteor.user().services.facebook.name;
var lastId;
var counter = 0;

var transactions =  Messages.find({userName: loggedUserName}, {sort: {time: -1}}).fetch();
var users = _.uniq(transactions,true, function(messages) {return messages.userName}); 

    users.forEach (function (row) {
         counter +=1;
                     });                     
    console.log(counter+ " number of users in Messages collection");

return users;}

});
</code></pre>

<p>Helper:</p>

<pre><code>&lt;template name="messages"&gt;
{{#each Names}}
    {{userName}} has {{unreadMessages}} Unread messages &lt;/br&gt;
{{/ each}}
&lt;/template&gt;
</code></pre>

<p>Yielding this</p>

<pre><code>Paul Otterson has 0 Unread messages
Vincent Guily has 1 Unread messages
</code></pre>

<p>Since some of the users have a specific number of unread messages, How do I write a helper code to display the number of unread messages per user? </p>

<p>To clarify I would like to achieve the below: </p>

<pre><code>Paul Otterson has 1 Unread messages
Vincent Guily has 2 Unread messages
</code></pre>

<p>Looking forward to your help.</p>