<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CANVAS</title>
</head>
<body>
<canvas width = "600" height = "400"></canvas>
<script>
function dibujarCuadrado(x,y){
var lienzo = document.querySelector("canvas");
var pincel = lienzo.getContext("2d");
pincel.fillStyle = "green";
pincel.fillRect(x,y,50,50);
pincel.strokeStyle = "black";
pincel.strokeRect(x,y,50,50);
}
for (i = 0; i < 3; i++){
x = (Math.round(Math.random()*100));
y = (Math.round(Math.random()*100));
dibujarCuadrado(x,y);
}
</script>
</body>
</html>