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

Tell us what’s happening: help, I am so confused, I tried every way I could think of but it didn’t work :frowning:

Step 90

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.

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 + ".";
    
  }
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36

Challenge Information:

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

You should post what you have tried. If you do not it makes it harder for us to help you with whatever it is you are specifically confused about.

You are asked to .push() the newWeapon variable onto the inventory array.

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