Dragon Slaying #4


#1

Why is this code not working?

var slaying = false;
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!");
} else {
console.log ("you missed!");
}
slaying = false;
}


#2

Hi @tagninja01056

Change the slaying's value in first line in true

Because while loop works only if salying is true, if it's false she doesn't work