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

Tell us what’s happening:

I keep getting the error message " You should use compound assignment to add one to currentWeapon .", and have tried several messages, have tried adding 1 to the index of weapons[i] to move to the next element in the array, but i can’t find my way around the error. I commented out what I’ve already tried

EDIT: here’s the link to the lesson

function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeapon++;
// currentWeapon += 1;
}
}

1 Like

please do not remove the link to the step, that’s pretty useful in trying to help you, can you add back the link to the step to your post?

added a link

(buffing character count so i can respond)

I can pass the test adding one of the two lines added in your code. Are you sure that’s the code you tried?

I am. i think my submit button was just broken. i refreshed my page and passed. thank you

It’s solution is simple, just add single line code
SOLUTION REDACTED BY MOD

Hey @Muhammad_Ibrar, It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

2 Likes

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