<meta charset="utf-8">
<canvas width="600" height="400"> </canvas>
<script type="text/javascript">
function desenhaQuadrado(x,y,cor,tamanho){
var tela = document.querySelector('canvas');
var pincel = tela.getContext('2d');
pincel.fillStyle = cor;
pincel.fillRect(x,y,tamanho,50,50);
pincel.strokeStyle = 'black';
pincel.fillStroke = 'yellow';
pincel.strokeRect(x,y,50,50);
}
for (var x = 0; x <= 150; x = x + 50){
if(x == 150){
desenhaQuadrado(x,0,'white',50);
}else{
desenhaQuadrado(x,0,'green',50);
}
}
</script>