Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day March 19, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    Consider the following program:

    let rect;
    
    function main() {
        rect = new Rectangle(getWidth() / 6, getHeight() / 6);
        rect.setPosition(getWidth() / 2 - rect.getWidth() / 2, 0);
        rect.setColor(Randomizer.nextColor());
        add(rect);
    
        mouseClickMethod(drop);
    }
    
    function drop() {
        setTimer(moveDown, 100);
    }
    
    function moveDown() {
        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?