Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day Feb. 4, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    The following program currently results in an error when run:

    let ball;
    
    function main() {
        let ball = createCircle(50, 200, 100, "green");
        changeBall();
    }
    
    function createCircle(radius, x, y, color) {
        let ball = new Circle(radius);
        ball.setPosition(x, y);
        ball.setColor(color);
        add(ball);
        return(ball);
    }
    
    function changeBall() {
        ball.setColor("orange");
    }
    
    main();
    JavaScript

    Which of the following would fix the program, resulting in an orange ball on the canvas?