I need to convert an array like the following:
["Cats", "Cats", "Dogs", "Dogs", "Dogs"]
the the following form:
[
{ x: "Cats", y: 35 },
{ x: "Dogs", y: 40 },
{ x: "Birds", y: 55 },
]
where y
represents the number of the same elements in the array.