I'm collecting an array of data, saving it as array of custom objects, then trying to map it to a table. I have a constructor for my object type:
function cellData(x, value, y){
this.x = x;
this.value = value;
this.y = y;
}
After gathering the data into an array of cellData objects, and i've already determined the necessary size of the table, I have two nested loops to loop through column/row and and map my data to a table:
for (var y2 = 0; y2 < yMax; y2++){
tableHtml += '<tr>';
for (var x2 = 0; x2 < xMax; x2++){
var cellMatch = new cellData();
cellMatch = cells.filter(cd => {
return cd.x == x2 && cd.y == y2 && cd.value;
});
console.log(cellMatch.value);
if (cellMatch != undefined) {
tableHtml += '<td>' + cellMatch.value + '</td>';
} else {
tableHtml += '<td> </td>';
}
}
tableHtml += '</tr>';
}
The issue i'm running into is I'm having trouble with my data output, and accessing the properties of my cellData objects. In my console logging, if I try to just log cellMatch on its own, I get the whole object. But when I try to log the value property, i'm getting undefined. What am I doing wrong here?
cellMatchvariable, independent of any other "problem" with the question. They got downvotes because people here are annoyed with beginners and gatekeep until the perfect question is made for some reason. There is a clear bug in the source code posted, that's what they wanted to know. Maybe staging ground should be a 3/3 vote then like when closing questions.