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

Tell us what’s happening:

I am having a bit of difficulties with this question: the step is
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.

The hint I’m receiving is: You should add the string You attack it with your to the text.innerText value. Remember that spacing matters.

appreciate the help

### Your code so far

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

}

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

Challenge Information:

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

What happens if you stick "attacks." and "You attack it with your " together?

This is the key part of the hint. How would those two sentences display? Would the spacing look right as written?

2 Likes

understood, thank you. Solved :smiley:

1 Like

Haha that’s a good one! :sweat_smile:

Thanks man, I was banging my head on the wall for past 25mins

This is a bs step imo. Because it says " On a new line, add the string You attack it with your <weapon>." I thought I was being clever adding a “\n”, “remember[ing] that spacing matters” and then dialed back to a simpler solution that still wasn’t working for ages. Infuriating.