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

Tell us what’s happening:

I cannot go to the next step. I saw on YT ( codeManS practice videos - for him it was step 88) that he passed this step with the same code I typed. What is wrong? And why does the text of the variable newWeapons turn light grey?

Your code so far

function buyWeapon() {
  if (gold >= 30) {
    gold -= 30;
    currentWeapon++;
    goldText.innerText = gold;
    let newWeapons = weapons;
    text.innerText = "You now have a new weapon.";
  }
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0

Challenge Information:

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

because it’s never user, editors can give useful infos like this

the issue your code is having is that you have the wrong variable name, it’s newWeapon not newWeapons

2 Likes

I strongly recommend against copying code from videos. You lean less than way.

1 Like