Problem with 6/6 javascript Dragon slay though i don't find any mistake


#1


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)
   {
       console.log("you hit the dragon with"+damageThisRound ) ;
        totalDamage += damageThisRound;
  if (totalDamage >=4) 
  {
      console.log("nice shot") ;
      slaying = false ;
  }
  else
  {
       youHit = Math.floor(Math.random() * 2);
  }
   else
   {
       console.log("dragon is better than you at this ") ;
    slaying = false ;
   }
} 
Replace this line with your code.


#2

Got a question or a description of what it should do differently?
Right now there's just code.


#3

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