Learn by building RPG - Dragon Repeller step 93

//link:

Up until now, any time text.innerText was updated, the old text was erased. This time, use the += operator to add text to the end of text.innerText.

Add the string In your inventory you have: - include the spaces at the beginning and the end.
//code
function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeapon++;
goldText.innerText = gold;
let newWeapon = weapons[currentWeapon].name;
text.innerText = "You now have a " + newWeapon + “.”;
text.innerText += “\n”+“In your inventory you have:”
inventory.push(newWeapon);
}
}

Please post a link to the step you are working on. Also, please post your current code. Also, please talk to us about what about the instructions or error message is confusing. Thanks

//link:

in the following step I am unable to understand what is these lines want to convey (Up until now, any time text.innerText was updated, the old text was erased. This time, use the += operator to add text to the end of text.innerText.
Add the string In your inventory you have: - include the spaces at the beginning and the end.)
Up until now, any time text.innerText was updated, the old text was erased. This time, use the += operator to add text to the end of text.innerText.

Add the string In your inventory you have: - include the spaces at the beginning and the end.
//code

function buyWeapon() {
  if (gold >= 30) {
    gold -= 30;
    currentWeapon++;
    goldText.innerText = gold;
    let newWeapon = weapons[currentWeapon].name;
    text.innerText = "You now have a " + newWeapon + ".";
    text.innerText += "\n"+"In your inventory you have:" 
    inventory.push(newWeapon);
  }
}

did you include the spaces as requested?

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 (').

yes! but not working. I got stuck what to do ?

what have you changed from the code in the first post?

as requested to add text.innerText in new line . i added \n to get the result in new line but not working

you need to write it in a new line in the editor, it is not requested to write a new line in the string

did you figure it out for me text.innerText += " In your inventory you have: " this worked

1 Like

Copy it like this:

Mod Edit SOLUTION REMOVED

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.

Above line of code is working thanks