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

Tell us what’s happening:

Can anyone help me with simplifying what i need to do for this

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 += 
}

// 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/127.0.0.0 Safari/537.36

Challenge Information:

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

This lesson requires you to use the innerText property with an addition assignment operator to assign this string.

" You attack it with your <weapon>."

However, the should be replaced wth the player’s current weapon. If you check your console, you’ll see what to replace it with.

is this correct

text.innerText += " You attack it with your " + monsters[fighting].name + .;

You are almost there mate. Make these two changes.

1.<weapon> should be replaced by this weapons[currentWeaponIndex].name this is the current weapon. This monsters[fighting].name will not work because it’s the monster’s name

  1. Finally, nest the full-stop in quotation marks so that it’s part of the string.

is this correct

text.innerText += " You attack it with your " + weapons[currentWeaponIndex]  + ".";

Something is missing here.

not sure what it is i am missing

I suggest you check the console, it’ll help you identify what is missing.

sorry i am a bit confused, what do you mean by console?

hi there!
there is a tab on the challenge editor called console, it help to debug the code.

1 Like

i have added the extra part and it still didn’t work

text.innerText += " You attack it with your " + weapons[currentWeaponIndex].name + ".";

Your code passed all tests on my end. Can you reset the lesson then run the same code again and see if your answer will be accepted?
Alternatively, if that fails, post your entire code here, maybe the problem lies in the other sections of your code.