I looked for the answeer and i find nothing about it. So my question is how can i make a checkerboard with just using js. When i open the site, it should askes the user how many rows and columns they want to have so if i say 5 rows and 5 columns it should generate a checkerboard with this. I should use a for-loop and if for this. Heres my Code i worked on.
<script type="text/javascript">
var row = prompt("Rows?", 10);
row = parseInt(row);
var column = prompt("Columns?", 10);
column = parseInt(column);
for(var i= 1;i<=column;i++)
{
for(var p= 1;p<=row;p++)
{
if(p % 2 == 0)
{
document.write(' <img src="schwarz.png" ' + "<br />");
{
document.write(' <img src="weiss.png" ' + "<br />");
}
}
}
}
</script>
Aucun commentaire:
Enregistrer un commentaire