location["button text"] is an array with three elements. Change the button1.innerText assignment to be the first element of that array instead.
Stumped on this. I think I’m supposed to point to "locations/button text/[0] not the location. That way if we change locations it will always choose the first button text out of the appropriate array for where I am? I understand the syntax isn’t right but way trying to show the path intentions.
function update(location) {
button1.innerText = location[“button text”];
button2.innerText = “Go to cave”;
button3.innerText = “Fight dragon”;
button1.onclick = goStore;
button2.onclick = goCave;
button3.onclick = fightDragon;
text.innerText = “You are in the town square. You see a sign that says "Store".”;
This is the code that is involved. Not sure if I don’t understand what is wanted or just don’t know the syntax to write it.
Thanks in advance!
Thanks johnpaul!
so my guess is that I am looking at the button text array, then picking first response out of the button text for that location.
i thought I had to include include the [0] within the brackets instead it works more like go to button text, then go to the first item.
I appreciate the help. I found it much less difficult to look up and understand info for css and html on the internet. JavaScript doesn’t appear to have the same resources to understand syntax or I just don’t understand it well enough yet.
but should it not be locations[“button text”][0] ?
because we have this variable declared:
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."
}
];
locations with a s, so why and how it works with location without an s.
Maybe there is something obvious that I am missing.