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

Tell us what’s happening:

Can some please help me out here. The instruction said: " Change your currentWeapon assignment to use the increment operator." I have tried series of method but I am still stuck.

A help will highly be appreciated!

Your code so far


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.

Please copy/paste all the editor code showing in the challenge from where you just linked.

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

Your browser information:

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

Challenge Information:

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

1 Like

Here’s how the increment operator works:

let y = 5;

y equals 6.

1 Like

Thank you so much. I am grateful for your help :pray:

1 Like

The increment operators ++ and – if left unchanged will always increase or decrease a value by 1 and output the change in the variable.

In this case all you would need to write is SOLUTION REMOVED

I hope this helps.

It did, thanks for the tip

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.