Lesson 5/ Second if Statement


#1

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


while (slaying) {
    
    if (youHit) {
        console.log ("Kill his ass");
        totalDamage += damageThisRound;

        if (totalDamage >= 4) {
        console.log ("Dragon is now finished");
        slaying = false;
        
        }  else {
        youHit = Math.floor)Math.random() * 2);
       
    }
   }  else {
        console.log ("Your dead bruh");
        slaying=false;
   }
    }

having a issue with this.. just a syntax error. I am sure it is something simple but I have trying to debug to no avail.


#2

You're missing semicolons (;) in the area where you're setting variables.

See:

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

#3

Update the code
if (youHit = true)
I think it will work if you update like this..