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

Tell us what’s happening:

I’m not sure how to add the weapon… the only thing I could think of is if it’s a ++ thing to increment through the array?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

function buyWeapon() {
  if (gold >= 30) {
    gold -= 30;
    let currentWeapon = weapons[0];
    currentWeapon += weapons[1];
    
  }
}

// User Editable Region

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.6 Safari/605.1.15

Challenge Information:

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

Hi there!
Compound assignment is +=
and
++ is increment
In this step you need compound assignment to add 1 to currentWeapon variable

Thank you! I realized in the next step I was jumping the gun with the increment. :rofl:

1 Like