Damage ends game


#1

I have a problem where once I deal damage it ends the game. How do I fix it so it goes back and attempts to hit the dragon again? Thanks in advance! Here's the code:

//Name of the Game
console.log("Welcome to Slayr. Good Luck!");

// Variables

var slaying = true;
var youHit = Math.floor(Math.random() * 2);
var damageThisRound = Math.floor(Math.random() * 5 + 1);
var totalDamage = 0;

/* While loop to check if slaying is still true, or basically that slaying is still going, i.e. dragon is still being attacked */

while(slaying)
{
if(youHit)
{
console.log("You hit the dragon and did " + damageThisRound + " damage!");
totalDamage += damageThisRound;

    if(totalDamage >= 4)
    {
        console.log("You have slayed the dragon!")
        slaying = false;
    }
    else
    {
        youHit = Math.floor(Math.random() * 2);
    }
}
else
{
    console.log("You missed and the dragon killed you.                     You lose.");
}

slaying = false;

}


#2

I fixed it! I fixed it! I FIXED IT!

The 2nd to last "}" should have been after the final "slaying = false;" statement.

Lol sorry to everyone who reads all my posts just to see me solve them in the replies. Thank you all for when I'm too dumb to see my mistakes and really do need your help.