It’s displaying and behaving correctly in the preview, but it’s not accepting my code. I’ve tried giving the text property to locations outside the curly braces, as a separate element in the array locations as well, with/without the parentheses after goTown, without the goTown function, with the text property as a string, and I’ve checked my capitals. I’m not sure what else I can do
Your code so far
/* User Editable Region */
const locations = [
{
name: "town square",
"button text": ["Go to store", "Go to cave", "Fight dragon"],
"button functions": [goStore, goCave, fightDragon],
text: goTown().innerText
}
];
/* User Editable Region */
So it says to give text the value from the goTown function; i’ve changed the colon to an equals, but not sure to assign the value without calling it from the function? does it still go in the ‘location’ array?
it doesn’t want to take it outside the array either. either outside the braces or the brackets. The console says the locations property should have a text value, and that value should be the string " You are in the town square…" which does come up in the preview.
const locations = [
text = goTown().text.innerText,
{
name: "town square",
"button text": ["Go to store", "Go to cave", "Fight dragon"],
"button functions": [goStore, goCave, fightDragon]
}
];
also tried
const locations = [
{
name: "town square",
"button text": ["Go to store", "Go to cave", "Fight dragon"],
"button functions": [goStore, goCave, fightDragon]
}
], text = goTown().text.innerText;
tried with a comma and a semi colon after the ]. I’m also getting timed out on my replies, if it seems like i’m taking a while. I appreciate your patience and working me through this.
What exactly is it trying to achieve? why doesn’t take the text property like it takes the other properties?
const locations =
[
{
name: "town square",
"button text": ["Go to store", "Go to cave", "Fight dragon"],
"button functions": [goStore, goCave, fightDragon]
}
],
text = goTown().text.innerText;
It wants you to add a text property to the object inside the location array, and use the same string for the value as the one found in goTown on the right-hand side of the text.innerText. It just wants you to duplicate the same string value. There is nothing dynamic or evaluated going on just a hard-coded string in two places.
wow thank you that was it. The instruction “Give this property the final text.innerText value from the goTown function.” really made me think i had to use the “text.innerText” ability.