I have very little experience with Javascript arrays. I have a complex enough requirement that I need to put my data into an array and then generate an HTML table. In this example, I have a multi-dimensional array here for a Leaderboard where each value is an array of the team's scores.
I've nested a forEach within a forEach to construct the rows and cells. However, I keep getting two 'undefined' responses at the top, one for each team. I think it has something to do with the thisValue part of the forEach method, but I can't stop it or replace it.
I'm sure this is not the proper way to set this up, but if it's possible to get this working with a minor tweak for now, it would be ideal. See images. Any help is appreciated!
leaderBoard.forEach(row);
function row(value,index,array)
{
document.write('<tr>' + value.forEach(cell) + '</tr>');
}
function cell(value,index,array)
{
document.write('<td>' + value + '</td>');
}
When I remove the reference to the cell function from the row function, it returns the arrays and the 'undefinedundefined' disappears. Note below that I removed '.forEach(cell)' and added the data tags.
function row(value,index,array)
{
document.write('<tr><td>' + value + '</td></tr>');
}

</td>, not a</tr>