Nested Objects (Need help with Spaceship task (7))

Firstly good evening from down under (Sydney).
I have been searching the forums for help on accessing the first element in the spaceship array for the captains favourite food.

This is the first time I’m posting a topic so excuse me if I get this wrong, I believe I have linked the task below with the code, however I’m not sure it will work.

Task 7.1 (Spaceship)

I’ve tried various different codes and keep getting errors. It seems so simple but I cant access the element in the ‘favourite foods’ array within the object.

HELP please :slight_smile:

paceship.crew.captain['favourite foods'] would give us the array. Once/after we retrieved the array, we can access it by index.

'favourite foods'[0] would give use the first character of the string. Just like arrays, strings can be accessed by index.

So I’m not writing it like this;

spaceship.crew.captain[‘favourite foods’[0]]



I’m actually laughing… I figured it out.

Im spelling favourite the English/Australian way!! all I had to do was spell it the American English way…

how stupid it took me like 40 minutes to figure that out hahahahah!!!

thanks for your help, you pretty much confirmed what I thought all along I just had to get it right!

1 Like