So I have this array of objects
audioFeatures = [
{danceability: 10, loudness: 2, instrumentalness: 4, energy: 5, acousticness: 7},
{danceability: 6, loudness: 3, instrumentalness: 8, energy: 9, acousticness: 5},
{danceability: 7, loudness: 5, instrumentalness: 6, energy: 2, acousticness: 5},
{danceability: 8, loudness: 10, instrumentalness: 9, energy: 7, acousticness: 2},
]
And I want to calculate a mean value for each property i.e. danceability should = (10+6+7+8)/4 and so on. I have got this working through a plethora of for loops but it seems really inefficient and I ideally want to end up with one object containing each mean value which I haven't figured out.
Does anyone know of a nice way of doing this. I'm coding this in JavaScript but any advise would be appreciated and I can try implement it. I have been trying map but can't quite get my head around how to apply it to this (maybe nested map lol, that's probably not a good idea)