I have probelm with this code can anyone help please


#1

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

    slaying = false;
    if(youHit==true){
         // slaying = false  
         else {
  youHit = Math.floor(Math.random() * 2);
     }

    console.log("You hit the dragon");
    } else  {  

console.log("The dragon defeated you");
slaying = false;
}

}


#2

What's the problem?


#3

the code does not run i don't know what the problem is?


#4

Knowing that you aren't able to execute it, I can try doing so myself.
While doing so, I get told that there's a syntax error:

[stdin]:10
         else {
         ^^^^
SyntaxError: Unexpected token else

#5

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