Hello everyone,
I'm currently facing a challenge in writing a JavaScript function that calculates the average values for an array of objects.
Below is the example array:
const array = [
{
createdAt: "2021-06-05",
value: 0.2
},
{
createdAt: "2021-06-05",
value: 0.2
},
...
]
The desired output should be:
const newArray = [
{
createdAt: "2021-06-05",
value: 0.467
},
...
]
I attempted to use array.map on CodePen but encountered some issues, as shown in this example.
If you have any suggestions or solutions, I would greatly appreciate it!