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

Tell us what’s happening:

I had tuck in the step 120 in the learn-basic-javascript-by-building-a-role-playing-game lesson of the javascript-algorithms-and-data-structures-v8 category.

Your code so far

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

Challenge Information:

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

Please talk to us about what is confusing or has you stuck in your own words. Thanks

you are missing a few elements but are almost there. you can remove the \n and replace it with a single space to add a space between “attacks.” and your next line. you also need to use dot notation to access your current weapon name… i hope this helps.

2 Likes

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

2 Likes

understood. i will do my best. just trying to help.

1 Like

when I’m trying to submit my work learn-basic-javascript-by-building-a-role-playing-game in step (step-120) of this course with my solution it doesn’t go through.
and that’s whay I get in the console :

Sorry, your code does not pass. Don’t give up.

You should add the string You attack it with your to the text.innerText value. Remember that spacing matters.

Thanks ! that helps a lot I passed this step finally :partying_face:

Hello Mohamed. I’m on the same issue. How were you able to rectify yours. I’ll share my code cos I’m really confused at the moment.

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

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

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