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

Tell us what’s happening:

I can’t find what is wrong with my code. Even the internet says it is correct. I have tried in another web browser and it is still failing. I am getting an error in my console log for the last line of the code saying unknown but there is nothing wrong there either.. please 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 -= monsters[fighting].level;
  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; rv:139.0) Gecko/20100101 Firefox/139.0

Challenge Information:

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

Hi @cjdonnelly2001

Check out the message in the console.

Happy coding

I was missing the last } the console was telling me there was an error on line 219 while it was actually missing on 190

But how would the error checking code know that you intended to have a closure there? It doesn’t know what you wanted to code.

The missing curly brace caused an error later in the code. Use that as a guide, or a clue, to find the problem.