canvas variable is used to hold the content of our canvas using the canvas ID, which we used in our
<canvas></canvas> tags. The
canvasElement variable is used to hold the context of the canvas. We assign
fillstyle so that the rectangle that we want to draw turns black when filled. We used
canvasElement.fillRect(x, y, w, h); for the shape of the rectangle. Where
x is the distance of the rectangle from the x axis;
y is the distance of the rectangle from the y axis; and
h are the width...