Learn Basic JavaScript by Building a Role Playing Game - Step 147

As the question said, I created the if statement below the health variable and called
isMonsterHit.

function attack() {
  text.innerText = "The " + monsters[fighting].name + " attacks.";
  text.innerText += " You attack it with your " + weapons[currentWeapon].name + ".";
  health -= getMonsterAttackValue(monsters[fighting].level);
  if (isMonsterHit){
           // or  isMonsterHit  ();  in here ?
  }
  monsterHealth -= weapons[currentWeapon].power + Math.floor(Math.random() * xp) + 1;
  healthText.innerText = health;
  monsterHealthText.innerText = monsterHealth;
  if (health <= 0) {
    lose();
  } else if (monsterHealth <= 0) {
    if (fighting === 2) {
      winGame();
    } else {
      defeatMonster();
    }
  }
}

I know I’m missing something very small but I’m a beginner and I can’t figure it out! Someone please help me solve this question.

Thank you in advance

The function call is properly placed, however you forgot some brackets.

2 Likes

Thank you very much for helping me. Appreciate it.

1 Like