Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day Feb. 13, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    Consider the following program:

    function main() {
        setTimer(draw, 900);
    }
    
    function drawRect(x, y, w, h, color) {
        let rect = new Rectangle(w, h);
        rect.setPosition(x, y);
        rect.setColor(color);
        add(rect);
    }
    
    function draw() {
        let width = 100;
        let height = 50;
        let color = Randomizer.nextColor();
        let centerX = getWidth() / 2 - width / 2;
        let centerY = getHeight() / 2 - height / 2;
        drawRect(centerX, centerY, width, height, color);
    }
    
    main();
    JavaScript

    Which of the following options would stop future rectangles from being added to the canvas?