Want to receive Question of the Day updates? Subscribe Here
JavaScript Question of the Day
March 19, 2025
IncorrectCorrectNo Answer was selectedInvalid Answer
Consider the following program:
let rect;functionmain(){
rect =newRectangle(getWidth()/6,getHeight()/6);
rect.setPosition(getWidth()/2- rect.getWidth()/2,0);
rect.setColor(Randomizer.nextColor());add(rect);mouseClickMethod(drop);}functiondrop(){setTimer(moveDown,100);}functionmoveDown(){
rect.move(0,5);}main();
JavaScript
If we wanted the rectangle rect to stop moving once it hits the bottom of the canvas, which of the following options would be best?