Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day March 4, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    The following program is supposed to allow a user to click on a graphic shape and move it to a new location on the canvas, but it’s not working properly. Choose the choice below that fixes the program.

    function main() {
        mouseMoveMethod(changePosition);
    }
    
    function changePosition(e) {
        let element = getElementAt(e.getX(), e.getY());
        if (element != null) {
            element.setPosition(e.getX(), e.getY());
        }
    }
    
    // Assume there is additional code that creates one or more graphics objects
    
    main();
    JavaScript