I have retrieved an array of tags for blog posts from a database.
Here is an example of the query result:
["apple","banana", "apple", "orange","grapes","mango","banana"];
I am looking to determine how many times each string is repeated within the array in order to create a tag cloud.
The desired final output would be:
[{name:"apple",count:2}, {name:"banana", count:2}, {name: "orange",count:1} ...];
In my project, I am utilizing lodash and prefer to use it if possible. However, plain JavaScript is also acceptable.