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

Tell us what’s happening:

My code isn’t passing. I am not sure what to change.

Your code so far

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 += "In your inventory you have: " + newWeapon + “.”;
inventory.push(newWeapon);

}
}

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 93

Hi @latisha12 ,

You’ve got this one in the bag – the only thing you’re missing is: include the spaces at the beginning and the end.

EDIT: Great eye @anon42932716 , didn’t even notice that – now that I’m looking into it a little more @latisha12 I see you have added newWeapon to the string " In your inventory you have: ". Should it be there? :blush:

I think we have similar brains, I’ve been stumped in almost the exact same way on the exact same steps as you have been.

1 Like

Hello @latisha12!

Do you notice the space ```below inventory.push(newWeapon);

I suggest you ```add the new text.innerText with the += operator there. Then add the text .

1 Like