Javascript Arrays: How to count poperty values

const myArray = ['a','b','c','a','c','a'];
var result  = {};
myArray.forEach(function(x) { result[x] = (result[x] || 0)+1; });
console.log(result);