Role playing game step 139

hi everyone,

Could someone help with this step?

I can see that the code looks wrong/doesn’t make much sense, but I did try to follow the instruction?

Step 139

Back to your attack function - inside the else if block, create another if and else statement. If the player is fighting the dragon (fighting would be 2), call the winGame function. Move the defeatMonster() call to the else block.

For this step, you will need to use the strict equality (===) operator to check if fighting is equal to 2. The strict equality operator will check if the values are equal and if they are the same data type.

code below:

    if (fighting === 2) {winGame();
   else {defeatMonster();
}
    }```
2 Likes

Can you please provide a link to the exercise?

1 Like

Structure of your if/else looks a bit off, curly braces not placed correctly:

https://www.w3schools.com/js/js_if_else.asp

if (hour < 18) {
  greeting = "Good day";
} else {
  greeting = "Good evening";
}
2 Likes

yes, a curly bracket was missing. thank you

3 Likes

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