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

Tell us what’s happening:

Your code so far

WARNING

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 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge Information:

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

Hi everyone!

Please I don’t really know my mistakes here. Can anyone help me out?

my code below:

`function attack() {
  text.innerText = "The " + monsters[fighting].name + " attacks.";
  text.innerText += " You attact it with your " + stick;

}`

Hello @Chuxylen82
The first thing I have to ask you is why does your posted code have back ticks? Is that an effect of posting or is that part of the real code?

The request says the following:

On a new line, use the addition assignment operator(+=),

You got that part

to add the string " You attack it with your ." to the text value, replacing with the player’s current weapon.

This part you got the literal string correct but the weapon (stick) is not.
How would you obtain the “player’s current weapon”? You have to pull it from the variable const weapons using the currentWeapon value.

Also Sentence is not correct. attact found instead of attack
@Chuxylen82

Hi @Chuxylen82

In addition to the advice from @hasanzaib1389, you also need to access the weapons array. The player should not try to fight the dragon with just a stick. Also, place a dot at the end of the sentence.

Happy coding

1 Like

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