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

Tell us what’s happening: the error showing but could not understand for what reason

Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Step 86
You should tell the player what weapon they bought. In between the two lines you just wrote, use let to initialize a new variable called newWeapon. Set this to equal weapons.

gold -= 30;
currentWeapon++;
goldText.innerText = gold;
let newWeapon = weapons[currentWeapon];
text.innerText = "You now have a new weapon.";

}
}

function fightSlime() {

Sorry, your code does not pass. Keep trying.

newWeapon should be initialised to have the value of weapons. Don’t forget your semi-colon.

Your browser information:

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

Challenge Information:

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

Hello @mahiralam1999

The requirement says:

Step 86
You should tell the player what weapon they bought. In between the two lines you just wrote, use let to initialize a new variable called newWeapon. Set this to equal weapons.

Set this to equal weapons , no one of them but all of them.
I agree the initial comment:

You should tell the player what weapon they bought.
Leads to confusion.

You should tell the player what weapon they bought. In between the two lines you just wrote, use let to initialize a new variable called newWeapon . Set this to equal weapons .
Do i need to insert by own or just add other method to it?

let newWeapon = weapons[currentWeapon];
text.innerText = “You now have a new weapon.”;
It’s just error for putting the value of weapons too early

weapons[currentWeapon] is just one weapon, right? What if it asks to create another variable that is set to all weapons. Should it be just one? Should you need to use indexing []?

Welcome to FFC forum. You didn’t need that [arry] value in above code.

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