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

Tell us what’s happening:

in this line i give the space in the end of string but still it give me error

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.

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

Challenge Information:

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

you need a space before You

i give space and i make new line
text.innerText += "\n You attack it with your. " + weapons[currentWeapon].name + ".";

you don’t need a new line, also you have an extra period.


i remove the space and still got error

You should use dot notation to access the innerText property of text on a new line.

Please post your code and not images. It looks like you commented out the code above.

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

Also, you need punctuation at the end of the string (the test will let you know).


I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

text.innerText += " You attack it with your " + weapons[currentWeapon].name;
i give space before the YOU

And what does the test tell you now?

my code is corret sir but main problem their is some problem of spacing :::(((((
text.innerText += " You attack it with your " + weapons[currentWeapon].name;

You should use dot notation to access the innerText property of text on a new line.

punctuation is still missing

You should not be getting that test message but this one.

You should use the concatenation operator to end your string with . .

If you do not see that message please post the code of the full function.

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