RPG game step 65

Hi, I’m on step 65 for basic Javascript. The prompt is:

" location["button text"] is an array with three elements. Change the button1.innerText assignment to be the first element of that array instead."

I currently have:

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

My code errors out. Though I have tried the following:
location[“button text”[0][0]];
[“button text”[0]];

Any ideas? Thank you.

Careful with the order here. You are getting item 0 from the string "button text", not the array location["button text"] !

Hello!

I am not sure if the location of the [0] is in the correct place. Maybe try not including it within the same brackets and see what happens.

I think that’s what I just said :laughing:

I was already typing when you came into and posted. Sorry but my arthritic hands are much slower than most people in the forum.
I still try to contribute and felt is worded differently.

Sure, it just comes off as weird to see posts only rephrasing what was already said instead of offering something new.

In any case @marie_ann, make sure you read what I said here. location["button text"] is the array you are indexing into, so you need to use the bracket notation with the 0 after this, not after the string "button text".

Thanks for the responses, appreciate it. However shortly after I posted to the forum, I ended figuring this out on my own.

It was placement of the index I initially had. Since this is a nested array, my code passed by using:

location [“button text”][0];

3 Likes