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

Tell us what’s happening: The question asks to just make an if statement with the given condition ‘isMonsterHit’. I really don’t know what the condition for the function that is called is supposed to be and the tip is not really giving me anything to go with.

The tip given is: “You should add an if statement which calls isMonsterHit in the condition.” Which I feel I have done.

### Your code so far

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){
    
  }
  monsterHealth -= weapons[currentWeapon].power + Math.floor(Math.random() * xp) + 1;
  healthText.innerText = health;
  monsterHealthText.innerText = monsterHealth;
  if (health <= 0) {
    lose();
  } else if (monsterHealth <= 0) {
    fighting === 2 ? winGame() : defeatMonster();
  }
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0

Challenge Information:

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

please show us the code you tried

1 Like

First post so was a bit lost on the formatting :slight_smile: Fixed and edited the post since I think I way overthought it initially, but still going just by the “straighforward” instructions I’m not getting anywhere.

I was struggling with this for a while, check your brackets (some missing and some unnecessary), also there is something missing at the end - something that all other lines have!

to call the function you need to use the round parenthesis after the function name. Like to call winGame you have written winGame()

1 Like

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