<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cuadrados con Ciclos FOR</title>
</head>
<body>
<canvas width="600" height="400"></canvas>
<script>
function dibujarCuadrado(x, y, width, heigth, color, lineaColor) {
var pantalla = document.querySelector("canvas");
var pincel = pantalla.getContext("2d");
pincel.fillStyle = color;
pincel.fillRect(x, y, width, heigth,);
pincel.strokeStyle = lineaColor;
pincel.strokeRect(x, y, width, heigth,);
}
for (var x = 0; x < 600; x = x + 50) {
dibujarCuadrado(x, 0, 50, 50, "red", "black");
dibujarCuadrado(x, 50, 50, 50, "yellow", "black");
dibujarCuadrado(x, 100, 50, 50, "green", "black");
}
</script>
</body>
</html>