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

Tell us what’s happening:

I have created the following function:

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

but it still says inventory should contain “stick” in the array and I cannot get further

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

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

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36

Challenge Information:

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

I suspect they explicitly want you to

set inventory to an array with the string stick.

Yeah, I have tried:

inventory = ["stick"];

And it worked, thank you!

1 Like