Tallying which color has a greater value in each array element for data. Then push the higher valued color into an empty object, and/or increment that color by 1. Lastly sort the totals object highest to lowest in terms of the totals property values and return highest valued color
Struggling with how to map over this structure array since property keys are not uniform. Should I destructure it?
*I can redesign data structure as needed, and if it's easier to solve with a different design, please let me know!
data = [
{ orange: 4, green: 4},
{ green: 0, yellow: 0},
{ yellow: 1, orange: 4 },
{ blue: 2, green: 1 },
{ blue: 2, yellow: 1 },
{ green: 3, yellow: 2 },
{ green: 1, blue: 3},
{ green: 5, yellow: 2 },
]
```
```
totals = {
blue: 3,
green: 2,
orange: 1,
}
```
solution:
```
highValueColor = blue
```
// PSEUDOCODE
//map over the array => data.map()
//identify highest value between two elements => propA - propB
//check to see if the color's (key) in the element has already been added to totals object
//IF the key does not yet exist, create a property in the tally object with the color(key) and set its value to 1
//IF the key is already listed in tally object, increment its property value by 1 => ++
//sort totals object => Math.max()
//return highest value color
`