<!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</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,);
}
var x = 0;
while (x < 600) {
dibujarCuadrado(x, 0, 50, 50, "red", "black");
dibujarCuadrado(x, 50, 50, 50, "yellow", "black");
dibujarCuadrado(x, 100, 50, 50, "green", "black");
x = x + 50;
}
</script>
</body>
</html>