Step 57
Create another property in your object called button functions
. Give this property an array containing the three functions assigned to the onclick
properties in the goTown
function. Remember that these functions are variables, not strings, and should not be wrapped in quotes.
(Here’s my code)
const locations = [
{
name: "town square",
"button text": ["Go to store", "Go to cave", "Fight dragon"]
"button functions": [goStore, goCave, fightDragon]
}
];
function goTown() {
button1.innerText = "Go to store";
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\".";
}
When I hit Ctrl + Enter or click on the button for “Check your code”, nothing happens at all. What am I doing wrong? I’ve tried button functions
without quotation marks, I’ve tried buttonFunction
, I’ve tried "buttonFunctions"
and I’ve consulted ChatGPT which has no clue why I’m not able to move on as it thinks my code is fine. Is this a bug in the beta?