Learn Basic JavaScript by Building a Role Playing Game Step 67

function update(location) {
  button1.innerText = location["button text"][0];
  button2.innerText = location["button text"][1];
  button3.innerText = location["button text"][2];
  button1.onclick = location["button functions"][0];
  button2.onclick = location["button functions"][1];
  button3.onclick = location["button functions"][2];
  text.innerText = "You are in the town square. You see a sign that says \"Store.\"";

I do not understand this solution. We do not have any location object in the program but only have locations object should it not be locations[“button text”][index] and locations[“button functions”][index]

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\"."
    name: "store",
    "button text": ["Buy 10 health (10 gold)", "Buy weapon (30 gold)", "Go to town square"],
    "button functions": [buyHealth, buyWeapon, goTown],
    text: "You enter the store."

Please post a link to the step. Thanks

You function has a parameter called location

1 Like

Thank you very much. Just realised i completely missed the below below code and was only searching for location object.

function goTown() {