Tell us what’s happening:
I’m trying to increase the currentWeaponIndex by + 1 and I believe my code should be correct. I’ve tried the longer version using currentWeaponIndex = currentWeaponIndex + 1; and I also tried to increment the variable using currentWeaponIndex++ and neither works. I’ve tried resetting the step too.
I’ve tried chat gpt and it says it is correct too haha
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeaponIndex = currentWeaponIndex + 1;
}
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 84