Can you tell me my mistakes?


#1



syntax error


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("congraltulation!! you hit the dragon");
        totalDamage += damageThisRound;

        if (totalDamage >= 4) {
            console.log("You WIN! player slew thedragon");
            slaying = false;
        } else {
            youHit = Math.floor(Math.random() * 2);
        }
    } else(youHit === 0) {
        console.log("You lose! You missed");
        slaying = false;
    }

}


#2

wow, that took me ages. You can't have any condition at a else clause:

else (youHit === 0) {

should be:

else {

else really means: everything else, if you are going to include conditions you might miss something


#3

@ericentrepreneur,
An ELSE statement does not take a condition
so change your

else (youHit === 0) {

into

else  {