var slaying=true; var youHit=Math.floor(Math.random()*2); var damageThisRound=Math.floor(Math.random()*5 + 1); var totalDamage=totalDamage+damageThisRound; while(slaying) { if (youHit===1) { console.log("you hit the dragon"); if (totalDamage$lt;=4) { console.log("you slew the dragon!"); slaying=false; } else { youhit=Math.floor(Math.random()*2); } } else { console.log("the dragon burnates you, you are dead"); } slaying=false; }