Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day March 10, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    We’ve set up animate to be called every time a key is pressed down on the keyboard:

    function main() {
        keyDownMethod(animate);
    }
    
    function animate(e) {
        ball.move(5, 5);
    }
    
    main();
    JavaScript

    How can we set up animate so that it will only move the ball if the up arrow on the keyboard is pressed?