I have probelm with this code can anyone help please


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;
         // slaying = false  
         else {
  youHit = Math.floor(Math.random() * 2);

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

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



What's the problem?


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


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:

         else {
SyntaxError: Unexpected token else


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