[Solved] JavaScript array to dictionary conversation based on count


function convert(data){
  var myMap = {}
  data.forEach(el => myMap[el] = myMap[el] != undefined ? myMap[el] + 1 : 1);
  return Object.keys(myMap).map(k => {return {name: k, y: myMap[k]}})
}

console.log(convert(['A','B','B','B','C','C','A','B']))

2

solved JavaScript array to dictionary conversation based on count