Take a look at that


#1


https://www.codecademy.com/courses/javascript-beginner-en-mrTNH-6VIZ9/0/4?curriculum_id=506324b3a7dffd00020bf661#

Oops, try again. Make sure you log a message to the console to let the player knows if (s)he won or lost!

var slaying = false;
var youHit = Math.floor(Math.random()*2);
var damageThisRound = Math.floor(Math.random()*5+1);
var totalDamage = 0;
while(slaying){
    if(youHits){
        
        console.log("hit");
        
        
if(youhit === 0){

    console.log("hits");
}
    
    
    
    else{
        console.log("The dragon defeated you");
    }
}
}
slaying = false;


#2

on line 1, you set slaying to false, this means the loop will never run

be careful you don't get infinity loop


#3

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