Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day Feb. 17, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    What would be the color of the circle object after the following program executes?

    let circle;
    let blue = "#3458eb"
    function main() {
        circle = drawCircle(100, getWidth() / 2, getHeight() / 2, "red");
        setTimer(animation, 100);
    }
    
    function drawCircle(radius, x, y, color) {
        circle = new Circle(radius);
        circle.setPosition(x, y);
        circle.setColor(color);
        add(circle);
        return(circle);
    }
    
    function animation() {
        circle.setColor(Randomizer.nextColor());
        circle.move(0, -5);
        if (circle.getY() - 100 <= 0) {
            makeBlue();
        }
        if (circle.getColor() == blue){
            stopAnimation();
        }
    }
    
    function makeBlue() {
        circle.setColor(blue);
    }
    
    function stopAnimation() {
        stopTimer(animation);
    }
    
    main();
    JavaScript