so I have a little sailboat with a drawing of the moon and the sun. How would I create a for loop so that the sailboat, moon and the sun all are repeated across the x and y axis’s without repeating the same instructions over and over. The code I made doesn’t run when I save it and open the file.
for(var x = 0; x <= 600; x+200)
{
for(var y = 0; y <= 600; y+200)
{
drawWholeBoat(ctx, 200, 300);
}
}
>Solution :
Replace with this code, check comments for details:
for (let x = 0; x <= 600; x += 200) {
for (let y = 0; y <= 600; y += 200) {
drawWholeBoat(ctx, x, y);
}
}