Step 83 - Learn Basic JavaScript by Building A Role Playing Game

I don’t understand what i need to do in this question

function buyWeapon() {
  if (gold >= 30) {
    gold -= 30;
    update (currentWeapon[1]);
  }
}```

can you give more infos? like the link to the step? what do the tests say?

Step 83

The value of the currentWeapon variable corresponds to an index in the weapons array. The player starts with a "stick", since currentWeapon starts at 0 and weapons[0] is the "stick" weapon.

In the buyWeapon function, use compound assignment to add 1 to currentWeapon - the user is buying the next weapon in the weapons array.

where are you adding 1 to curretnWeapon?

i added it in my ‘if’ function but i think i did it wrong.

I don’t see it, that’s why I am asking. There isn’t an addition of 1 to currentWeapon. Do you remember how you add a number to a number? You already did something similar a few lines above

1 Like

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