<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Curso de Logica 2</title>
</head>
<body>
<canvas width="600" height="400"></canvas>
<script>
var tela = document.querySelector('canvas');
var pincel = tela.getContext('2d');
function desenhaEsquadro(xa, ya, xb, yb, cor) {
pincel.fillStyle = cor;
pincel.beginPath();
pincel.moveTo(xa,ya);
pincel.lineTo(xa,yb);
pincel.lineTo(xb,yb);
pincel.fill();
}
var cores = ['blue', 'red'];
var i=0
while (i<cores.length){
console.log(cores[i]);
desenhaEsquadro(50, 50, 400, 400, cores[i]);
i++;
console.log(cores[i]);
desenhaEsquadro(100, 175, 275, 350, cores[i]);
i++;
}
</script>