0

function stopTimer() {
    clearInterval(timer);
    var isHovered = $('#theEnd').is(":hover");
    if (isHovered == "True") {
        return youWon();
    }
    else {
        alert("You lost! try again!")
    }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Unfortunately, the code always defaults to the else statement even when I'm hovering over the div element with the id="theEnd"

sickguy125
  • 15
  • 3

1 Answers1

0

isHovered is already a boolean, you don't need to check if it is true or false just do this:

if (isHovered) {
    // ...
ibrahim mahrir
  • 31,174
  • 5
  • 48
  • 73