My JavaScript array/object consists of the following data:
[
{
"name": "A",
"selected_color": "Red"
},
{
"name": "B",
"selected_color": "Green"
},
{
"name": "C",
"selected_color": "Blue"
},
{
"name": "D",
"selected_color": "Red"
}
]
What steps should I take to transform it into the desired format below?
[
{
"color": "Red",
"count": "2"
},
{
"color": "Green",
"count": "1"
},
{
"color": "Blue",
"count": "1"
}
]
I aim to filter values based on the 'selected_color' key and keep track of how many times each specific color was selected.