JSFiddle - React, Tailwind, and code Playground
JavaScript
var array_elements = ["2","1","2","2","3","4","3","3","3","5"];
var result = array_elements.reduce(function(p, c){
if (c in p) {
p[c]++;
} else {
p[c]=1;
}
return p;
}, {});
console.log(result);