My code says "SyntaxError: Unexpected token ILLEGAL" Please help!


#1


It says that a token is ILLEGAL but I don't quiet understand what and where my mistake is.


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 === 1) { 
        console.log("Congratulations, you hit the dragon!");
         totalDamage += damageThisRound;
         if (totalDamage >= 4) { 
             console.log("You slew the Dragon!); 
             slaying = false;
         } else { 
             youHit === Math.floor(Math.random() * 2); 
         };
             
    } else { 
        console.log("The dragon defeated you, young one!"); 
        }; 
        slaying = false 
};


#2

You did not close the quotation mark here,

should be,

console.log("You slew the Dragon!");


#3

Thank you, Bandit. I can't believe i missed that.


#4

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