Check Collision detector

function checkCollision(x, y, hitboxWidth, hitboxHeight) {

          if (
                x >= hitboxX &&
                x <= hitboxX + hitboxWidth &&
                y >= hitboxY &&
                y <= hitboxY + hitboxHeight
            ) {
                return true;
            }
            return false;
        }