I have the following function:
function generateObject(){
var newarray = [],
thing;
//console.log(matrixData);
for(var i = 0; i < matrixData.data.length; i++){
console.log('Date: '+matrixData.data[i][0]);
console.log('Total: '+matrixData.data[i][1]);
thing = {};
for(var y = 0; y < matrixData.data[i][2].data.length; y++){
console.log(matrixData.data[i][2].data[y]);
}
// newarray.push(matrixData.data[i][0]);
// console.log(newarray);
}
}
what I am currently getting from the console log I would need to push inside an array which would look like this:
[
[matrixData.data[i][0] matrixData.data[i][2].data[y] matrixData.data[i][1]]
[matrixData.data[i][0] matrixData.data[i][2].data[y] matrixData.data[i][1]]
[matrixData.data[i][0] matrixData.data[i][2].data[y] matrixData.data[i][1]]
]
I would then 'return' the 'newarray' inside the 'generateObject' function and pass it inside a jQuery load template.
I am having problems achieving the above array.
I would expect and end result like this ion the console:
Simply push the objects, and return newarray
function generateObject(){
var newarray = [],
thing;
//console.log(matrixData);
for(var i = 0; i < matrixData.data.length; i++){
console.log('Date: '+matrixData.data[i][0]);
console.log('Total: '+matrixData.data[i][1]);
thing = {};
for(var y = 0; y < matrixData.data[i][2].data.length; y++){
//console.log(matrixData.data[i][2].data[y]);
newarray.push(matrixData.data[i][2].data[y]);
}
// newarray.push(matrixData.data[i][0]);
// console.log(newarray);
}
return newarray;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.