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

**URL:** <https://forum.freecodecamp.org/t/learn-basic-javascript-by-building-a-role-playing-game-step-149/661501>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [January 5, 2024, 2:46pm UTC](https://forum.freecodecamp.org/t/learn-basic-javascript-by-building-a-role-playing-game-step-149/661501 "2024-01-05T14:46:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![opeyemifrancis88](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/opeyemifrancis88/32/337942_2.png) [@opeyemifrancis88](https://forum.freecodecamp.org/u/opeyemifrancis88)\
**Post date:** [January 5, 2024, 2:46pm UTC](https://forum.freecodecamp.org/t/learn-basic-javascript-by-building-a-role-playing-game-step-149/661501/1 "2024-01-05T14:46:39Z")

</div>

### Tell us what’s happening: how do i create an if statement to set the to call isMonsterHit function

### Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

```plaintext
function attack() {
  text.innerText = "The " + monsters[fighting].name + " attacks.";
  text.innerText += " You attack it with your " + weapons[currentWeapon].name + ".";
  health -= getMonsterAttackValue(monsters[fighting].level);

  monsterHealth -= weapons[currentWeapon].power + Math.floor(Math.random() * xp) + 1;
  healthText.innerText = health;
  monsterHealthText.innerText = monsterHealth; 
  if (isMonsterHit){isMonsterHealth();}
  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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0`

### Challenge Information:

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

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-basic-javascript-by-building-a-role-playing-game/step-149)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![marcusparsons](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/marcusparsons/32/411768_2.png) [@marcusparsons](https://forum.freecodecamp.org/u/marcusparsons)\
**Post date:** [January 5, 2024, 2:51pm UTC](https://forum.freecodecamp.org/t/learn-basic-javascript-by-building-a-role-playing-game-step-149/661501/2 "2024-01-05T14:51:45Z")

</div>

Hey @opeyemifrancis88,

Please do not make a second post for the exact same topic so that we can keep the forum clean. I deleted your previous post for you.

In the challenge rules, they want you to put that if statement below the line where health is subtracted. The condition of the if statement is meant to be what is returned from the function `isMonsterHit` so you will need to **call that function** in your if statement. And then think about what the purpose of that if statement is, and make a judgment call on what should go inside of the curly braces. It should be something that would be based on if the monster was hit such as the monster’s health.

---

<div class="post-metadata">

**Author:** ![opeyemifrancis88](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/opeyemifrancis88/32/337942_2.png) [@opeyemifrancis88](https://forum.freecodecamp.org/u/opeyemifrancis88)\
**Post date:** [January 5, 2024, 2:54pm UTC](https://forum.freecodecamp.org/t/learn-basic-javascript-by-building-a-role-playing-game-step-149/661501/3 "2024-01-05T14:54:41Z")

</div>

Thank you, will not make sure not to post exact same topic next time. Meanwhile, i already passed the code, thanks for your assistance.

---

<div class="post-metadata">

**Author:** ![marcusparsons](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/marcusparsons/32/411768_2.png) [@marcusparsons](https://forum.freecodecamp.org/u/marcusparsons)\
**Post date:** [January 5, 2024, 2:56pm UTC](https://forum.freecodecamp.org/t/learn-basic-javascript-by-building-a-role-playing-game-step-149/661501/4 "2024-01-05T14:56:25Z")

</div>

Closed on January 5, 2024, 2:56pm UTC


