My code is not working, keep geeting unexpected else


#1

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

while (slaying) {
slaying = false
if(youHit = true){
console.log("Congratulation, you just dealt the dragon a blow")
totalDamage += damageThisRound}
if (totalDamage >= 4){
console.log("the dragon is dead bro")
slaying = false}
else
youHit = Math.floor(Math.random() * 2)

        }

 else{
    console.log("you are finished")
    }

#2

You have an Else statement on line 14 which has no brackets, no nothing, and you can't place two else's after each other.


#3

i just added the curly bracket now, its still not working. I cant place two else statement together, but have two if statement, how do i that


#4

Your last Else statement shouldn't need to be an else statement, just add it as a command.


#5

okk, thanks a lot
You the boss


#6

No problem, please Like and mark as solved :wink: Have fun coding! :smile: