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

Tell us what’s happening:

The code is asking for text.innerText but I am already using it.

Your code so far

function attack() {
text.innerText = “The " + monsters[fighting].name + " attacks.”;
text.innerText = "you attack it with your " + monsters[weapon];


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.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

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

Challenge Information:

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

the first line of these two is useless because the second one replaces it immediately, is that what you want? Or maybe you want to concatenate the two?
btw, the text need to be exactly what given, so you want to use You with an uppercase Y

Neither. This is the instruction.

On a new line, add the string You attack it with your [weapon]. to the text value, replacing [weapon] with the player’s current weapon.

“add the string to the value” not replace

Right now you are using the assignment operator here

but as was mentioned earlier, that is incorrect.

Look to line 133 of the code to see the correct operator that you need to use to add the string.

Once you fix that, you have two more issues to resolve

The next one is the spacing here

Remember that spacing matters at the beginning of the sentence. Also, make sure your sentence starts with a capital letter as mentioned earlier too.

The last issue is this part here

The directions want you to target the players current weapon.
The hint text will tell you the correct syntax for getting the current weapon.

Once you fix those things, then the test will pass

hope that helps

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