Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day March 14, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    The following code adds a circle to the screen that follows the cursor around when it hovers over the canvas:

    let circle;
    const RADIUS = 50;
    
    function main() {
        circle = new Circle(RADIUS);
        circle.setPosition(getWidth() / 2, getHeight() / 2);
        add(circle);
    
        mouseMoveMethod(move);
    }
    
    function move(e) {
        let x = e.getX();
        let y = e.getY();
    // insert code here
    
        circle.setPosition(x, y);
    }
    
    main();
    JavaScript

    Which of the following options would prevent the circle from moving off of the canvas on the right-hand side when added to the move function?