4/6 Nothing seems to work


#1

I'm quite sure my entire code is correct and I've tried many different ways of logging a win or lose message to the console but none of them are being accepted. Could anyone help?

My code:

while (slaying) {
    if (youHit){
        console.log("Congatulations! You hit the dragon.");
    }
    else {
        console.log("My apologies. You have been slain by the dragon.");
    }
    slaying = false;
};

My error message:

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

#2

Let me see your whole code please :slight_smile:


#3

Hi anathemastyles,

It's a simple fix just make youHit == true or 1 in the paramaters in the if statement.

Hope This helped.


#4

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("Congatulations! You hit the dragon.");
    }
    else {
        console.log("My apologies. You have been slain by the dragon.");
    }
    slaying = false;
};

#5

Set this variable to true


#6

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