<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<canvas width="600" height="400">
</canvas>
<script>
function dc(x,y,color) {
var pantalla = document.querySelector("canvas");
var pincel = pantalla.getContext("2d");
pincel.fillStyle = color;
pincel.fillRect(x,y,50,50);
pincel.strokeStyle = "black"
pincel.strokeRect(x,y,50,50)
}
/*
var x = 0;
while(x < 600){
dc(x,0,"red");
dc(x,50,"yellow");
dc(x,100,"green");
x = x + 50;
}
*/
for (var x = 0; x < 600; x = x + 50) {
dc(x,0,"red");
dc(x,50,"yellow");
dc(x,100,"green");
}
</script>
</body>
</html>