I'm still trying to navigate inside the map function but still need a little bit of help.
I'm trying to to gather all storeArea values in one individual array, and all totalStore.date values into different individual array.
when I'm using map im getting for totalStore.date 6 arrays within an object. whats the right and correct thing to do?
Thanks!
var results =[]
var stores_json = {
"stores": [
{
"storeArea": "area1",
"totalStore": [
{
"date": "2018-10-01"
},
{
"date": "2018-11-01"
},
{
"date": "2018-12-01"
}
]
},
{
"storeArea": "area2",
"totalStore": [
{
"date": "2018-10-01"
},
{
"date": "2018-11-01"
},
{
"date": "2018-12-01"
}
]
},
{
"storeArea": "area3",
"totalStore": [
{
"date": "2018-10-01"
},
{
"date": "2018-11-01"
},
{
"date": "2018-12-01"
}
]
},
{
"storeArea": "area4",
"totalStore": [
{
"date": "2018-10-01"
},
{
"date": "2018-11-01"
},
{
"date": "2018-12-01"
}
]
},
{
"storeArea": "area5",
"totalStore": [
{
"date": "2018-10-01"
},
{
"date": "2018-11-01"
},
{
"date": "2018-12-01"
}
]
},
{
"storeArea": "area6",
"totalStore": [
{
"date": "2018-10-01"
},
{
"date": "2018-11-01"
},
{
"date": "2018-12-01"
}
]
}
]
}
results = stores_json["stores"].map(function (x) {
return [x.storeArea, x.totalStore.map(function (y) {
var dates = [y.date]
return dates
})]
});
datevalues in one single array and the same for storeArea. sorry for the mixup