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

Tell us what’s happening: Its my code wrong? I don’t get what’s the issue it just don’t give any hints neither…

Step 88 this is what it asks for:

Use bracket notation to access an object within the weapons array and assign it to your newWeapon variable. Place the variable currentWeapon within the brackets.

When you use a variable in bracket notation, you are accessing the property or index by the value of that variable.

For example, this code uses the index variable to access a value of array.

let value = array[index];

Your code so far

function buyWeapon() {
if (gold >= 30) {
gold -= 30;
goldText.innerText = gold;
let newWeapon = weapons;
text.innerText = “You now have a new weapon.”;
let newWeapon = weapons[currentWeapon];


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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15

Challenge Information:

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

Hi José! Welcome! You have accidentally defined the variable twice. I recommend deleting the second one and putting the code requested on the first one.

1 Like