There three functions or methods that draw rectangles on the canvas.
fillRect method is used to draw a filled rectangle.
var variableName = canvas.getContext(2d);
variableName.fillRect(x,y,width,height);
strokeRect method is used to draw a rectangular outline.
var variableName = canvas.getContext(2d);
variableName.strokeRect(x,y,width,height);
strokeRect method is used to clear or erase specified rectangular area, making it fully transparent.
var variableName = canvas.getContext(2d);
variableName.clearRect(x,y,width,height);
You can draw any number of rectagnle and also you can clear any area or rectangle.
Open notepad or any other text editor, follow the following points.
save file with name task.html or task.htm and then open it using any browser and see results.