Declare your variables dragon slaying


#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("Congratulations, you hit the dragon!");
       
    } else {
        console.log("The dragon defeated you.");
    }
    var slaying = false;
};

says that slaying is not set to true ?


#2

solved my issue. slaying = false needed to be outside the loop. thanks for viewing it though


#3

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