1
I have a one-dimensional array of 100 positions and how to get me to draw a 10x10 matrix (table) using a loop for.
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var x= [];
for (i=0; i< 100; i++)
{
x[i] = "X";
}
var texto;
texto = "<table>";
for (i=0; i< (x.length/100); i++)
{
texto += "<tr>";
for (i=(x.length)-1; i< x.length; i++) //como resolver isso? ????
{
texto += "<td>" + x[i] + "</td>";
}
texto += "</tr>";
}
texto += "</table>";
document.getElementById("demo").innerHTML = texto;
</script>
</body>
</html>
What I did didn’t need to use auto increment inside the loop, as shown in the @Diego Felipe code. But thank you anyway.
– Leandro
Very good your code alternative. Mark your answer as solved so that others can consult in the future,
– user28595
How do I mark as resolved?
– Leandro
Just click the green arrow below the reply counter.
– user28595
thanks. I clicked on the arrow but a warning was displayed which I can only resolve after two days.
– Leandro
When you answer your own question, the system requires that to accept it, it must be published at least two days ago. I’m not sure what the purpose of this restriction is.
– Victor Stafusa