Working but not perfect '8'


#1

This is while i Hit the Dragon:
- You hit the Dragon
- Player slew the dragon
- TypeError: slaying is not a function

Dragon defeated you:
There is no Error showing in the console.

Can anyone explain where is the problem pls.

Thanks

var slaying = true;
var youHit = Math.floor(Math.random() * 2)
var damageThisRound = Math.floor(Math.random() * 5 + 1)
var totalDamage = 0;
//var slaying = true;
while(slaying) {   
slaying = false;
    if (youHit === 1){
        console.log("You hit the Dragon");
    if (totalDamage += totalDamage + damageThisRound >= 4);
        console.log("Player slew the dragon");
        slaying = false;
    if (totalDamage >= 4);
        slaying (youHit);
    }
    else { 
        (youHit === 0)
        console.log("Dragon defeated you");
    }
   
};


#2

There is definitely a problem with the brackets which will need to be addressed. The error message is referring to this line:

The lines above this need some modification.

    if (youHit === 1) {

may be written,

    if (youHit) {

but this is not an issue. It takes into account truthy, which 1 is. It evaluates to true in a conditional expression.

Be sure to close the if block before the else.

    if (youHit) {
        //
        //
        if (totalDamage ...) {
            //
        }
    } else {

    }

Does this exercise have an example in lesson 1?