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

Strugging to complete challange

what is wrong with my array assignment
Instructions : 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 .

MY CODE SO FAR

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

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

Your browser information:

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

Challenge Information:

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

Hi @thembank

Just a few touch ups required.

  1. remove [0] after the variable
  2. nest the string in square brackets

Happy coding

1 Like

Thanks for the speedy help!

2 Likes

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