I have a canvas and I draw a rectangle in one function, in a new function I need to print this square a random number of times between 5 and 10
I know I have to use Math.floor(Math.random() * 5) + 5; but now what I need to do to print the rectangle randomly 5 or 10 times?
this is what I've got so far, but not sure how to make it work
function rectangle() {
ctx.beginPath();
ctx.rect(20, 20, 150, 100);
ctx.stroke();
}
function randomRect(){
Math.floor(Math.random() * 5) + 5;
rectangle()
}
Aucun commentaire:
Enregistrer un commentaire