I am missing something... Part5


#1

Hi, going over this code, but cant seem to find the bug. Can someone help me out.

Cheers in advance.


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===true){
        console.log("congratulations you hit the dragoni");
        totalDamage += damageThisRound; 
            if (totalDamage >= 4) {
                console.log("Player has slain the dragoni");
                slaying = false;
            }
            else{
                (youHit = Math.floor(Math.random()*2);
            }
            
    }
    else{
        console.log("You got eaten. Sorry dude");
    slaying = false;
    }
}

.


#2

SOLVED.

I was missing an additional closing bracket for my else statement.

Thanks


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.