Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day Feb. 14, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    What will happen when the following program executes?

    let ball;
    
    function main() {
        ball = new Circle(40);
        add(ball);
        setTimer(draw, 20);
    }
    
    function draw(){
        ball.move(2, 2);
        if (ball.getX() == getWidth() / 2) {
            stopAnimation();
        }
    }
    
    function stopAnimation(){
        stopTimer(draw);
    }
    
    main();
    JavaScript