Learn Basic JavaScript by Building a Role Playing Game - Step 67

I made this

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

I don’t understood who is the problems

Challenge Information:

Learn Basic JavaScript by Building a Role Playing Game - Step 67

1 Like
button1.onclick = goStore[“button functions”][0];
button2.onclick = goCave[“button functions”][1];
button3.onclick = fightDragon[“button functions”][2];

Hi this is the code you wrote please note that you must use the parameter name same as this code you wrote:

button1.innerText = location[“button text”][0];
button2.innerText = location[“button text”][1];
button3.innerText = location[“button text”][2];

I hope this works you already solved the problem but with a small accidentally mistake.
(both code are yours i didnt edit any).

1 Like

not work: when you use ‘’ it signed like an error
it is better ", then I don’t understood the differences! xD

What didn’t work? What did you change? Please post your updated code.


button3.onclick = location[“x”][x];

here is a small guide for you.

it need the double quote (") instead of two single quote (')

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

I tried to change de double quotes with the singles ’

goStore isn’t an array.
goCave isn’t an array.
fightDragon isn’t an array.

You need to use the locations array.

That isn’t using the locations array

yes then I deleted the reply xD

Hey @MaryGothic,
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

thank you!

    button1.innerText = location['button text'][0];

    button2.innerText = location['button text'][1];

    button3.innerText = location['button text'][2];

    button1.onclick = goStore['button functions'][0];

    button2.onclick = goCave['button functions'][1];

    button3.onclick = fightDragon['button functions'][2];

    text.innerText = "You are in the town square. You see a sign that says \"Store.\"";
1 Like
    button1.innerText = location['button text'][0];
    button2.innerText = location['button text'][1];
    button3.innerText = location['button text'][2];
    button1.onclick = goStore['button functions'];
    button2.onclick = goCave['button functions'];
    button3.onclick = fightDragon['button functions'];
    text.innerText = "You are in the town square. You see a sign that says \"Store.\"";

Preformatted textlike this?

You’re using goStore like an array. You can’t, because it’s not an array. You need to use the locations array.

button1.onclick = location["button functions"][0];
button2.onclick = location["button functions"][1];
button3.onclick = location["button functions"][2];

Closer. You are indexing into the array, so the number comes first.

1 Like