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

Tell us what’s happening:

I cant figure out what the issue is !!! what am i suppose to do to make the if statement ive tried everything!

Your code so far

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

/* file: styles.css */

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

if currentWeaponIndex < 3;
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 {
    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/132.0.0.0 Safari/537.36

Challenge Information:

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

o que voce esta fazendo aqui?
if currentWeaponIndex < 3;

i dont speak portugese but i translated and you asked what i was doing there, so ill answer. i was trying to check if currentWeaponIndex is less than 3

oh i removed the unnecessary character and added parentheses and i got it

1 Like

…and that is the correct sintaxe for a If statement?

I already solved it no need to problem solve

outside the function? it should be inside the function

if it passed with the if statement outside the function please tell us, it would be a grave bug

1 Like