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

Tell us what’s happening:

My code seems not to run; despite doing research and reviewing past discussions on this same topic-the role playing game for the javascript course. I also noticed my preview screen is blank at this step. I would appreciate any form of help

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

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

  }
  monsterHealth -= weapons[currentWeaponIndex].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();
    }
  }
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

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

You may have accidentally deleted the closing parantheses ) of the getMonsterAttackValue() function on the line right above your if statement.

It should be:

health -= getMonsterAttackValue(monsters[fighting].level);

For the next time, if you don’t see anything wrong with your code, there is chance that you may accidentally mess up other code.
In that case, just reset and try again first.

i fix it you should write
code removed by moderator

then replace code removed by moderator inside you if block

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