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

Tell us what’s happening:

I’m not sure what is wrong with this code. It looks like it should run, but I cannot pass it.

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 " += currentWeapon + ".";  
}

// User Editable Region

Your browser information:

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

Challenge Information:

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

you can’t have two += on the same line, and you can’t have a string on the lefthand side of one of those. Make the right one a simple concatenation operator

Thanks so much. It worked.

Hi there!

You didn’t need equal addition operator before the current weapon variable. Also you need to access the weapons array indexing currentWeapon and the name property using bracket and dot notation.

1 Like