New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Because when you draw rectangles on top of each other, you don't hide the old ones, they are always there in white. After each loop, draw a black rectangle on top of the previous position of the box, to do that, add this line at the end of your draweverything function:
canvascontext.fillStyle = "black";
canvascontext.fillRect(ballx-10, 300, 10, 10);