I'm starting with javascript and I have this problem I'm trying to return and array with the data but when I console log I get "[object Object][object Object]"
this is the data I have to work with
var MARKDATA = {
"SOR": {
"mark": [
{
"data": {
"2015": 21.680000,
"2016": 23.739999,
"2017": 23.760000
},
"markName": "swimming",
"markCode": "SWM"
},
{
"data": {
"2015": "",
"2016": 61.55429840,
"2017": 61.482299804
},
"markName": "running (time)",
"indicatorCode": "RM"
}
]
}
};
this is what I tried
const valuesArr= MARKDATA.SOR.mark;
let acum= '';
const showData = arr => {
const dataArr= arr.map(value => value.data).join('')
acum += dataArr;
};
showData(valuesArr);
console.log(acum)
I want that console log returns and array with the years and the values of the object data, what I want to do is use this array to calculate with the reduce method the average of each data.
Or if someone knows a better way to get the average of the values of the object data I will apreciate it
acumwith a string (''), then using+=. The+=is doing string concatenation.jointo do ?