title: How to count the number of the same items in an array and assign the count to a particular key in an object?
body: <p>I need to convert an array like the following:</p>
  
  <pre class="lang-js prettyprint-override"><code>["Cats", "Cats", "Dogs", "Dogs", "Dogs"]
  </code></pre>
  
  <p>the the following form:</p>
  
  <pre class="lang-js prettyprint-override"><code>[
      { x: "Cats", y: 35 },
      { x: "Dogs", y: 40 },
      { x: "Birds", y: 55 },
  ]
  </code></pre>
  
  <p>where <code>y</code> represents the number of the same elements in the array.</p>