Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day April 25, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    Consider the following program:

    let player;
    const URL = "https://codehs.com/player";
    
    function main() {
        player = createPlayer(100, 100, URL);
        keyDownMethod(move);
    }
    
    function createPlayer(x, y, image) {
        let character = new WebImage(image);
        character.setPosition(x, y);
        add(character);
        return(character);
    }
    
    // YOUR MOVE FUNCTION
    
    main();
    JavaScript

    Choose the option below that will successfully implement a move() function that will allow the user to move the player left or right when the arrow keys are pressed.