Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day Feb. 21, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    Consider a game that has a ball colliding with a rectangle. The logic that checks for the collision is the following:

    if (ball.getX() >= rect.getX() && ball.getX() <= rect.getX() + rect.getWidth()) {
        if (ball.getY() + ball.getRadius() >= rect.getY()) {
            // A collision has occurred!
        }
    }
    JavaScript

    At what points on the ball and rectangle does this logic check for a collision?