canvas width="600" height="400"></canvas>
<script>
function quadrado(x, y ,cor){
var tela = document.querySelector("canvas");
var pincel = tela.getContext("2d");
pincel.fillStyle = cor;
pincel.fillRect(x, y, 50, 50);
pincel.strokeStyle = "black";
pincel.strokeRect(x, y, 50, 50);
}
var x = 0;
while (x < 600){
var y = 0;
quadrado(x,y, "green");
while(y<400){
quadrado(x,y, "green");
y = y + 50;
}
x = x + 50;
}
</script>