Looking for assistance with the following code snippet:
The simpleData array retrieves data from a server.
var secondaryData = [];
this.simpleData.forEach(function(team,teamIndex) {
let p0=0,p1=0,p2=0,p3=0,p4=0;
team.components.forEach(function(component,index) {
let tempData = []; //Single Dimensional array
p0 = component.priority0;
p1 = component.priority1;
p2 = component.priority2;
p3 = component.priority3;
p4 = component.priority4;
tempData.push(p0);tempData.push(p1);tempData.push(p2);
tempData.push(p3);tempData.push(p4);
secondaryData[teamIndex][index].push(tempData);
});
});
My goal is to create a two-dimensional array where secondaryData[team][component] will store an array of values calculated. However, I am encountering an undefined error at secondaryData. Any assistance would be appreciated.
Here is the structure of the simpleData array:
[{"name":"abc","components":[{"name":"name1","a0":0,"a1":6,"a2":36,"a3":44,"a4":59},....]}]