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

Tell us what’s happening:

Help me solve it for some reason it doesn’t work out

function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeaponIndex++;
goldText.innerText = gold;
let newWeapon = weapons[currentWeaponIndex].name;
text.innerText = "You now have a " + newWeapon + “.”;
inventory.push(newWeapon);
text.innerText += " In your inventory you have: " + inventory;
}
else if(currentWeaponIndex <3 ){
gold -= 30;
currentWeaponIndex++;
goldText.innerText = gold;
le

Your code so far

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

/* file: styles.css */

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

function buyWeapon() {
  if (gold >= 30) {
    gold -= 30;
    currentWeaponIndex++;
    goldText.innerText = gold;
    let newWeapon = weapons[currentWeaponIndex].name;
    text.innerText = "You now have a " + newWeapon + ".";
    inventory.push(newWeapon);
    text.innerText += " In your inventory you have: " + inventory;
  } 
  else if(currentWeaponIndex <3 ){
     gold -= 30;
    currentWeaponIndex++;
    goldText.innerText = gold;
    let newWeapon = weapons[currentWeaponIndex].name;
    text.innerText = "You now have a " + newWeapon + ".";
    inventory.push(newWeapon);
    text.innerText += " In your inventory you have: " + inventory;
  }
  
  else {
    text.innerText = "You do not have enough gold to buy a weapon.";
  }
}

// User Editable Region

Your browser information:

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

Challenge Information:

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

reset the step, and add an if statement around all the code in your function as instructed