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

Tell us what’s happening:

Your code so far

function restart() {
  xp=0;
  health = 100;
  gold = 50;
  currentWeapon=0;
  inventory [0] = weapons[currentWeapon].name;
  goldText.innerText = gold;
  healthText.innerText = health;
  xpText.innerText = xp;
  goTown();
}

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.

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

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0
i have tried several different methods to insert the ‘string’ of “stick” into the array. I believe that this should give the value of inventory the string “stick” Where am I wrong.

Challenge Information:

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

What hint are you getting?

At the end of your code, create a restart function. Inside this function, set xp to 0, health to 100, gold to 50, currentWeapon to 0, and set inventory to an array with the string stick.

Also update the innerText properties of goldText, healthText, and xpText to their current values.

Finally, call the goTown() function.

Those are the instructions, not the hint you are getting after checking your code. When you click the “Check Your Code” button and it doesn’t pass, you should see a hint below the button. That’s what I am asking you about?

Your restart function should set inventory to an array with the string stick .

inventory = [“stick”];

Can you post your full updated code for us?

Right now you wrote

If you have made changes, then it would help to see your full code to better assist you

I fixed it with the above reply.