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

function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeapon++;
goldText.innerText = gold;
let newWeapon = weapons[currentWeapon].name;
text.innerText = "You now have a " + newWeapon + “.”;
arr.push(newWeapon);
}
} Back at the beginning of this project, you created the inventory array. Add the newWeapon to the end of the inventory array using the push() method.

Here is an example:

Please fill out the form. We need you to tell us the problem your are having and add you code.

do you have a variable named arr in your code?

no
should i have to add that in this step

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)
}
}

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.