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

Tell us what’s happening:

  1. Your second locations object should have a button text property which is an array.
  2. Your button text property should have the string values “Buy 10 health (10 gold)”, “Buy weapon (30 gold)”, and “Go to town square”.
  3. Your second locations object should have a button functions property which is an array.
  4. Your button functions property should have the function values buyHealth, buyWeapon, and goTown.
  5. You should not modify the first locations object.

Your code so far

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

/* file: styles.css */

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

const locations = [
  {
    name: "town square",
    buttonText: ["Go to store", "Go to cave", "Fight dragon"], // ✅ Correct property name
    buttonFunctions: [goStore, goCave, fightDragon] // ✅ Correct functions
  },
  {
    name: "store",
    buttonText: ["Buy 10 health (10 gold)", "Buy weapon (30 gold)", "Go to town square"], // ✅ Correct property name
    buttonFunctions: [buyHealth, buyWeapon, goTown], // ✅ Correct property name
    text: "You enter the store." // ✅ This remains unchanged
  }
];


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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 59

I suggest you reset the step to get the code back how it was. The existing code for town square had 2 of the keys differently to how you have done them. You have also changed the original.

Change the syntax / format for those 2 keys and it should pass.

As a reminder of what the key is:
key: value of key

1 Like

Welcome to the forum :wave:

Have a look at the original code:

const locations = [
  {
    name: "town square",
    "button text": ["Go to store", "Go to cave", "Fight dragon"],
    "button functions": [goStore, goCave, fightDragon],
    text: "You are in the town square. You see a sign that says \"Store\"."
  }
];

Examine the color highlighting to see how you’ve changed this syntax.

2 Likes