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

this step 93 why here is problem

function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeapon++;
goldText.innerText = gold;
let newWeapon = weapons[currentWeapon].name;
text.innerText += "In your inventory you have: " + newWeapon + β€œ.”;
inventory.push(newWeapon);

}

in this step ,they only need you to add the string In your inventory you have: with spaces in beginning and the end

In addition, do not interfere with any other code, you deleted a section of this code and replaced it with the current section.

text.innerText += "In your inventory you have: " + newWeapon + β€œ.”;
1 Like

where i wright this above push() function or not

I suggest you leave the other sections of your code as they are, you don’t wanna arise some new issues.

1 Like

listen when i wright this code wright this code above push() function
so problem say that You should add a new line with text.innerText .

Whether you write it above or below, the code still passes, if it doesn’t then it means you have a problem with the code.

1 Like

this is my code but here is say not done

function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeapon++;
goldText.innerText = gold;
let newWeapon = weapons[currentWeapon].name;
text.innerText += "In your inventory you have: " + newWeapon + β€œ.”;
inventory.push(newWeapon);

}
}

Kindly take your time and make the changes as advised, anyone else in the forum will give you the same response.

1 Like

i understand but when wright
text.innerText += "In your inventory you have: " + newWeapon + β€œ.”;
then pronblem show You should add a new line with text.innerText .
i try many time but problem not fixing sir

Ok. Do this, reset the lesson, so that you can regain some code that you deleted. This is the original block of code:

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

In your code, you got rid of this

 text.innerText = "You now have a " + newWeapon + ".";

Then you replaced it with this

text.innerText += "In your inventory you have: " + newWeapon + β€œ.”;

You are not supposed to interfere with that line of code.

2 Likes