Hi All,
I have reviewed the forum but still do not get it how and why function update (location) is used to get const locations = object as function update(locations), just swaps the specific lines when locations called?
Could you please describe me as if was a 5 years old child?
Thank you in advance for your help.
I am here at the moment:
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."
}
];
function update(location) {
button1.innerText = location["button text"[0]];
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\".";
};
function goTown() {
update(locations[0]);