I need assistance with calculating the average of ratings within nested array objects that are inside another array. Below is the array provided:
let arr = [
[{"category":"behavioural", "rating":3}, {"category":"technical", "rating":4.5}],
[{"category":"behavioural", "rating":1}, {"category":"technical", "rating":2.5}],
[{"category":"behavioural", "rating":4}, {"category":"technical", "rating":2}]
]
The goal is to compute the average rating for each category and then save it in an object.
Desired outcome:
"metricsaverage" : {
"behavioral" : 2.66,
"technical" : 3
}
In this output, 2.66 and 3 represent the average ratings of all items belonging to their respective categories from the nested array of objects.