why this code doent work? What’s wrong with it:

let spaceship = {

crew: {

captain: { 

    name: 'Lily', 

    degree: 'Computer Engineering', 

    cheerTeam() { console.log('You got this!') } 


'chief officer': { 

    name: 'Dan', 

    degree: 'Aerospace Engineering', 

    agree() { console.log('I agree, captain!') } 


medic: { 

    name: 'Clementine', 

    degree: 'Physics', 

    announce() { console.log(`Jets on!`) } },

translator: {

    name: 'Shauna', 

    degree: 'Conservation Science', 

    powerFuel() { console.log('The tank is full!') } 




for(let crewMemberName in{

console.log(${crewMemberName}: ${spaceship.crew[crewMemberName].degree});


name is not a property of crew.

for {crewmember in spaceship.crew) {}

Now crewmember is one of the contained properties, ‘captain’, ‘chief officer’, ‘medic’, ‘translator’, each of which have a name property.

Owing that crewmember is a variable we cannot use dot notation. Instead we need to use subscript (bracket) notation.

1 Like

Thanks! I guess I need to be a little more cautious!

1 Like