I have an array of objects like this:
const test = [
{
"id": "1"
"date": "2022-03-11 21:00:00"
"temp": "200",
"desc": "light clouds"
},
{
"id": "2"
"date": "2022-03-11 22:00:00"
"temp": "220",
"desc": "light clouds"
},
{
"id": "3"
"date": "2022-03-11 23:00:00"
"temp": "205",
"desc": "rainy clouds"
},
{
"id": "4"
"date": "2022-03-12 21:00:00"
"temp": "180",
"desc": "light clouds"
},
{
"id": "5"
"date": "2022-03-12 22:00:00"
"temp": "200",
"desc": "rainy"
},
{
"id": "6"
"date": "2022-03-12 23:00:00"
"temp": "200",
"desc": "rainy"
},
]
What I want to do is to map over these objects and find the average temp for each day with the same date. And then also find the desc which appears the most times for that date too.
I am not really sure where to even begin, I am guessing I will have to use a map() function and then .find() but unsure of the syntax.
Comments
Post a Comment